From ef1bca842b526345218421f271ac5349fdc94cfa Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Mon, 15 Jan 2024 00:37:01 -0800 Subject: [PATCH 1/2] Ensure DataCollector cleans up after itself --- silk/collector.py | 1 + 1 file changed, 1 insertion(+) diff --git a/silk/collector.py b/silk/collector.py index 912b9298..de9d7a3a 100644 --- a/silk/collector.py +++ b/silk/collector.py @@ -59,6 +59,7 @@ def request(self, value): def _configure(self): self.local.objects = {} self.local.temp_identifier = 0 + self.stop_python_profiler() self.local.pythonprofiler = None @property From 1832b4203ff6306cbc489144563b55da5c41684e Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Mon, 15 Jan 2024 20:44:40 -0800 Subject: [PATCH 2/2] Clean up after tests --- project/tests/test_execute_sql.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/project/tests/test_execute_sql.py b/project/tests/test_execute_sql.py index 7e9c5b20..e84fdd62 100644 --- a/project/tests/test_execute_sql.py +++ b/project/tests/test_execute_sql.py @@ -52,6 +52,9 @@ def setUpClass(cls): super().setUpClass() call_execute_sql(cls, None) + def tearDown(self): + DataCollector().stop_python_profiler() + def test_called(self): self.mock_sql._execute_sql.assert_called_once_with(*self.args, **self.kwargs) @@ -65,6 +68,9 @@ def setUpClass(cls): super().setUpClass() call_execute_sql(cls, Request()) + def tearDown(self): + DataCollector().stop_python_profiler() + def test_called(self): self.mock_sql._execute_sql.assert_called_once_with(*self.args, **self.kwargs) @@ -77,6 +83,9 @@ def test_query(self): class TestCallSilky(TestCase): + def tearDown(self): + DataCollector().stop_python_profiler() + def test_no_effect(self): DataCollector().configure() sql, _ = mock_sql() @@ -89,6 +98,9 @@ def test_no_effect(self): class TestCollectorInteraction(TestCase): + def tearDown(self): + DataCollector().stop_python_profiler() + def _query(self): try: query = list(DataCollector().queries.values())[0]