Skip to content

Commit

Permalink
Merge pull request #699 from albertyw/profile-cleanup
Browse files Browse the repository at this point in the history
Always disable cProfile as part of cleanup
  • Loading branch information
albertyw authored Jan 19, 2024
2 parents 7bc0f26 + 1832b42 commit 3a8bebc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions project/tests/test_execute_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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()
Expand All @@ -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]
Expand Down
1 change: 1 addition & 0 deletions silk/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3a8bebc

Please sign in to comment.