File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -418,15 +418,15 @@ def _django_use_model(request):
418418 else :
419419 models = (model ,)
420420
421- with contextlib . closing ( connection .schema_editor () ) as schema :
421+ with connection .schema_editor () as schema :
422422 schema .deferred_sql = []
423423 for model_class in models :
424424 if not hasattr (model , '_meta' ):
425425 raise ValueError ('"model" must be a valid model class' )
426426 schema .create_model (model_class )
427427
428428 def drop ():
429- with contextlib . closing ( connection .schema_editor () ) as schema :
429+ with connection .schema_editor () as schema :
430430 for model_class in models :
431431 schema .delete_model (model_class )
432432
Original file line number Diff line number Diff line change @@ -141,6 +141,8 @@ def test_transactions_enabled(self):
141141 assert not connection .in_atomic_block
142142
143143
144+ @pytest .mark .skipif (not hasattr (connection , 'schema_editor' ),
145+ reason = "This Django version does not support SchemaEditor" )
144146@pytest .mark .django_db
145147class TestUseModel :
146148 """Tests for django_use_model marker"""
@@ -163,10 +165,20 @@ def test_unmanaged_destroyed(self):
163165 self .test_unmanaged_missing ()
164166
165167
166-
167- @pytest .mark .django_use_model (Unmanaged )
168+ # TODO: Remove this next test before release
169+ @pytest .mark .skipif (not hasattr (connection , 'schema_editor' ),
170+ reason = "This Django version does not support SchemaEditor" )
171+ @pytest .mark .django_db
172+ @pytest .mark .django_use_model (model = Unmanaged )
168173def test_marked_test_not_get_hit ():
169- assert True is False
174+ """
175+ A failing test like this was originally added to demonstrate that adding
176+ "@pytest.mark.django_use_model(ModelClass)" caused a test not to be
177+ collected. It's left here to demonstrate that it's now being collected
178+ when called with model=ModelClass instead; it should be removed before
179+ the next release.
180+ """
181+ assert "This test failing shows that it is being collected and run" is False
170182
171183
172184def test_unittest_interaction (django_testdir ):
You can’t perform that action at this time.
0 commit comments