Skip to content

Commit 843bac8

Browse files
authored
Fix test flakyness (#100)
1 parent ec66da9 commit 843bac8

File tree

5 files changed

+186
-2
lines changed

5 files changed

+186
-2
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ dev = [
4949
"coverage",
5050
"django-guardian",
5151
"graphviz",
52+
"mypy",
5253
"pre-commit",
5354
"pytest",
5455
"pytest-cov",
5556
"pytest-django",
57+
"pytest-randomly",
5658
"tox",
5759
]
5860

tests/testapp/tests/test_basic_transitions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ def setUp(self):
138138
pre_transition.connect(self.on_pre_transition, sender=SimpleBlogPost)
139139
post_transition.connect(self.on_post_transition, sender=SimpleBlogPost)
140140

141+
def tearDown(self):
142+
pre_transition.disconnect(self.on_pre_transition, sender=SimpleBlogPost)
143+
post_transition.disconnect(self.on_post_transition, sender=SimpleBlogPost)
144+
141145
def on_pre_transition(self, sender, instance, name, source, target, **kwargs):
142146
assert instance.state == source
143147
self.pre_transition_called = True
@@ -166,6 +170,10 @@ def setUp(self):
166170
pre_transition.connect(self.on_pre_transition, sender="testapp.SimpleBlogPost")
167171
post_transition.connect(self.on_post_transition, sender="testapp.SimpleBlogPost")
168172

173+
def tearDown(self):
174+
pre_transition.disconnect(self.on_pre_transition, sender="testapp.SimpleBlogPost")
175+
post_transition.disconnect(self.on_post_transition, sender="testapp.SimpleBlogPost")
176+
169177

170178
class TestFieldTransitionsInspect(TestCase):
171179
def setUp(self):

tests/testapp/tests/test_exception_transitions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ def setUp(self):
2828
post_transition.connect(self.on_post_transition, sender=ExceptionalBlogPost)
2929
self.post_transition_data = {}
3030

31+
def tearDown(self):
32+
post_transition.disconnect(self.on_post_transition, sender=ExceptionalBlogPost)
33+
3134
def on_post_transition(self, **kwargs):
3235
self.post_transition_data = kwargs
3336

tests/testapp/tests/test_multi_resultstate.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ def setUp(self):
4949
pre_transition.connect(self.on_pre_transition, sender=MultiResultTest)
5050
post_transition.connect(self.on_post_transition, sender=MultiResultTest)
5151

52+
def tearDown(self):
53+
pre_transition.disconnect(self.on_pre_transition, sender=MultiResultTest)
54+
post_transition.disconnect(self.on_post_transition, sender=MultiResultTest)
55+
5256
def on_pre_transition(self, sender, instance, name, source, target, **kwargs):
5357
assert instance.state == source
5458
self.pre_transition_called = True

0 commit comments

Comments
 (0)