5
5
from __future__ import annotations
6
6
7
7
import inspect
8
- from typing import TYPE_CHECKING
9
8
10
9
import django .test
11
10
import pytest
16
15
from pytest_django .asserts import __all__ as asserts_all
17
16
18
17
19
- if TYPE_CHECKING :
20
- import django .test
21
-
22
-
23
18
def _get_actual_assertions_names () -> list [str ]:
24
19
"""
25
20
Returns list with names of all assertion helpers in Django.
@@ -81,23 +76,23 @@ def test_sanity() -> None:
81
76
assert assertContains .__doc__
82
77
83
78
84
- def test_real_assert (django_testcase : django .test .TestCase ) -> None :
79
+ def test_fixture_assert (django_testcase : django .test .TestCase ) -> None :
85
80
django_testcase .assertEqual ("a" , "a" ) # noqa: PT009
86
81
87
82
with pytest .raises (AssertionError ):
88
83
django_testcase .assertXMLEqual ("a" * 10_000 , "a" )
89
84
90
85
91
86
class TestDjangoAssert (django .test .TestCase ):
92
- def test_real_assert (django_testcase : django .test .TestCase ) -> None :
87
+ def test_fixture_assert (django_testcase : django .test .TestCase ) -> None :
93
88
django_testcase .assertEqual ("a" , "a" ) # noqa: PT009
94
89
95
90
with pytest .raises (AssertionError ):
96
91
django_testcase .assertXMLEqual ("a" * 10_000 , "a" )
97
92
98
93
99
94
class TestInternalDjangoAssert :
100
- def test_real_assert (self , django_testcase : django .test .TestCase ) -> None :
95
+ def test_fixture_assert (self , django_testcase : django .test .TestCase ) -> None :
101
96
django_testcase .assertEqual ("a" , "a" ) # noqa: PT009
102
97
assert not hasattr (self , "assertEqual" )
103
98
@@ -112,10 +107,13 @@ def test_unittest_assert(django_pytester: DjangoPytester) -> None:
112
107
import unittest
113
108
114
109
class TestUnittestAssert(unittest.TestCase):
115
- def test_real_assert (self, django_testcase: unittest.TestCase) -> None:
110
+ def test_fixture_assert (self, django_testcase: unittest.TestCase) -> None:
116
111
assert False
112
+
113
+ def test_normal_assert(self) -> None:
114
+ self.assertEqual("a", "a")
117
115
"""
118
116
)
119
117
result = django_pytester .runpytest_subprocess ()
120
- result .assert_outcomes (failed = 1 )
118
+ result .assert_outcomes (failed = 1 , passed = 1 )
121
119
assert "missing 1 required positional argument: 'django_testcase'" in result .stdout .str ()
0 commit comments