Skip to content

Commit 3bd2773

Browse files
committed
add test
1 parent 6992412 commit 3bd2773

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

tests/test_unittest.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ def tearDown(self):
5858

5959
def test_sole_test(django_testdir):
6060
"""
61-
Make sure the database are configured when only Django TestCase classes
61+
Make sure the database is configured when only Django TestCase classes
6262
are collected, without the django_db marker.
63-
"""
6463
64+
Also ensures that the DB is available after a failure (#824).
65+
"""
6566
django_testdir.create_test_module(
6667
"""
6768
import os
@@ -80,11 +81,26 @@ def test_foo(self):
8081
8182
# Make sure it is usable
8283
assert Item.objects.count() == 0
84+
85+
assert 0, "trigger_error"
86+
87+
class TestBar(TestCase):
88+
def test_bar(self):
89+
assert Item.objects.count() == 0
8390
"""
8491
)
8592

8693
result = django_testdir.runpytest_subprocess("-v")
87-
result.stdout.fnmatch_lines(["*TestFoo*test_foo PASSED*"])
94+
result.stdout.fnmatch_lines(
95+
[
96+
"tpkg/test_the_test.py::TestFoo::test_foo FAILED",
97+
"tpkg/test_the_test.py::TestBar::test_bar PASSED",
98+
'> assert 0, "trigger_error"',
99+
"E AssertionError: trigger_error",
100+
"E assert 0",
101+
"*= 1 failed, 1 passed in *",
102+
]
103+
)
88104
assert result.ret == 0
89105

90106

0 commit comments

Comments
 (0)