Skip to content

Commit

Permalink
test/threads: fix state leakage across tests
Browse files Browse the repository at this point in the history
test_threaded_bad_options was only passing in CI because it was running
after test_threaded_invalid_binary, which altered the base class to
ignore some exceptions.

Restructure the tests by using the fact that ThreadedAustin.join will
bubble up any exception that happened during startup. This avoids
manipulating global state in test_threaded_invalid_binary.

Fixes P403n1x87#13.
  • Loading branch information
delroth committed Oct 31, 2022
1 parent 4292f1c commit 473501f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions test/test_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ def assert_callbacks_called(self):
class InvalidBinaryThreadedAustin(ThreadedAustin):
BINARY = "_austin"

@check_raises(AustinError)
def run(self, *args, **kwargs):
super().run(*args, **kwargs)


def test_threaded():
austin = TestThreadedAustin()
Expand Down Expand Up @@ -109,8 +105,10 @@ def terminate_callback(*args):


def test_threaded_invalid_binary():
SimpleAustin.start = check_raises(AustinError)(SimpleAustin.start)
InvalidBinaryThreadedAustin(sample_callback=lambda x: None).start(["python"])
austin = InvalidBinaryThreadedAustin(sample_callback=lambda x: None)
austin.start(["python"])
with raises(AustinError):
austin.join()


def test_threaded_no_sample_callback():
Expand All @@ -121,4 +119,5 @@ def test_threaded_no_sample_callback():
def test_threaded_bad_options():
austin = TestThreadedAustin(terminate_callback=lambda *args: None)
austin.start(["-I", "1000", "python", "-c", "for i in range(1000000): print(i)"])
austin.join()
with raises(AustinError):
austin.join()

0 comments on commit 473501f

Please sign in to comment.