@@ -83,15 +83,6 @@ def test_fixture_assert(django_testcase: django.test.TestCase) -> None:
8383 django_testcase .assertXMLEqual ("a" * 10_000 , "a" )
8484
8585
86- class TestDjangoAssert (django .test .TestCase ):
87- def test_fixture_assert (self , django_testcase : django .test .TestCase ) -> None :
88- assert django_testcase == self
89- django_testcase .assertEqual ("a" , "a" ) # noqa: PT009
90-
91- with pytest .raises (AssertionError ):
92- django_testcase .assertXMLEqual ("a" * 10_000 , "a" )
93-
94-
9586class TestInternalDjangoAssert :
9687 def test_fixture_assert (self , django_testcase : django .test .TestCase ) -> None :
9788 assert django_testcase != self
@@ -102,6 +93,27 @@ def test_fixture_assert(self, django_testcase: django.test.TestCase) -> None:
10293 django_testcase .assertXMLEqual ("a" * 10_000 , "a" )
10394
10495
96+ @pytest .mark .django_project (create_manage_py = True )
97+ def test_django_test_case_assert (django_pytester : DjangoPytester ) -> None :
98+ django_pytester .create_test_module (
99+ """
100+ import django.test
101+
102+ class TestDjangoAssert(django.test.TestCase):
103+ def test_fixture_assert(self, django_testcase: unittest.TestCase) -> None:
104+ assert False, "Cannot use the fixture"
105+
106+ def test_normal_assert(self) -> None:
107+ self.assertEqual("a", "a")
108+ with pytest.raises(AssertionError):
109+ self.assertXMLEqual("a" * 10_000, "a")
110+ """
111+ )
112+ result = django_pytester .runpytest_subprocess ()
113+ result .assert_outcomes (failed = 1 , passed = 1 )
114+ assert "missing 1 required positional argument: 'django_testcase'" in result .stdout .str ()
115+
116+
105117@pytest .mark .django_project (create_manage_py = True )
106118def test_unittest_assert (django_pytester : DjangoPytester ) -> None :
107119 django_pytester .create_test_module (
@@ -110,7 +122,7 @@ def test_unittest_assert(django_pytester: DjangoPytester) -> None:
110122
111123 class TestUnittestAssert(unittest.TestCase):
112124 def test_fixture_assert(self, django_testcase: unittest.TestCase) -> None:
113- assert False
125+ assert False, "Cannot use the fixture"
114126
115127 def test_normal_assert(self) -> None:
116128 self.assertEqual("a", "a")
0 commit comments