Skip to content

Commit

Permalink
introduce TestCaseWithBrokenTearDown class
Browse files Browse the repository at this point in the history
This class will implement the scenario of a test case with a broken tearDown() method, which throws an exception every time it's ran.

Checklist:
- run tearDown even if the test fails 👈🏼

---

Output:
➜ python3 src/test_case_test.py
6 run, 1 failed
  • Loading branch information
kaiosilveira committed Mar 19, 2023
1 parent 59a7384 commit d3dc78b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/broken_teardown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from test_case import TestCase

class TestCaseWithBrokenTearDown(TestCase):
def __init__(self, name: str) -> None:
TestCase.__init__(self, name)

def testMethod(self) -> None:
pass

def tearDown(self) -> None:
raise Exception
1 change: 1 addition & 0 deletions src/test_case_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from test_result import TestResult
from broken_setup import TestCaseWithBrokenSetup
from test_suite import TestSuite
from broken_teardown import TestCaseWithBrokenTearDown

class TestCaseTest(TestCase):
def setUp(self) -> None:
Expand Down

0 comments on commit d3dc78b

Please sign in to comment.