File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -495,3 +495,44 @@ def test_method(self):
495495 result = django_testdir.runpytest_subprocess("--pdb")
496496 result.stdout.fnmatch_lines(["*= 1 passed in *"])
497497 assert result.ret == 0
498+
499+
500+ def test_teardown_behavior(django_testdir):
501+ django_testdir.create_test_module(
502+ """
503+ from unittest import SkipTest
504+ from django.test import TestCase
505+
506+ post_teardown_count = 0
507+
508+ class TestClass1(TestCase):
509+
510+ def _post_teardown(self):
511+ global post_teardown_count
512+ post_teardown_count += 1
513+
514+ def test_1_skip(self):
515+ self.addCleanup(lambda: print("clean1"))
516+ assert post_teardown_count == 0
517+ raise SkipTest("skipped!")
518+
519+ def test_2_pass(self):
520+ self.addCleanup(lambda: print("clean2"))
521+ assert post_teardown_count == 1
522+
523+ def test_3_fail(self):
524+ self.addCleanup(lambda: print("clean3"))
525+ assert post_teardown_count == 2
526+ assert 0, "fail"
527+ """
528+ )
529+
530+ result = django_testdir.runpytest_subprocess("--pdb", "-s")
531+ result.stdout.fnmatch_lines([
532+ "tpkg/test_the_test.py clean1",
533+ "sclean2",
534+ ".clean3",
535+ "F",
536+ "*> entering PDB >*",
537+ "*= 1 failed, 1 passed, 1 skipped in *",
538+ ])
You can’t perform that action at this time.
0 commit comments