File tree 2 files changed +17
-5
lines changed
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):
418
418
else :
419
419
models = (model ,)
420
420
421
- with contextlib . closing ( connection .schema_editor () ) as schema :
421
+ with connection .schema_editor () as schema :
422
422
schema .deferred_sql = []
423
423
for model_class in models :
424
424
if not hasattr (model , '_meta' ):
425
425
raise ValueError ('"model" must be a valid model class' )
426
426
schema .create_model (model_class )
427
427
428
428
def drop ():
429
- with contextlib . closing ( connection .schema_editor () ) as schema :
429
+ with connection .schema_editor () as schema :
430
430
for model_class in models :
431
431
schema .delete_model (model_class )
432
432
Original file line number Diff line number Diff line change @@ -141,6 +141,8 @@ def test_transactions_enabled(self):
141
141
assert not connection .in_atomic_block
142
142
143
143
144
+ @pytest .mark .skipif (not hasattr (connection , 'schema_editor' ),
145
+ reason = "This Django version does not support SchemaEditor" )
144
146
@pytest .mark .django_db
145
147
class TestUseModel :
146
148
"""Tests for django_use_model marker"""
@@ -163,10 +165,20 @@ def test_unmanaged_destroyed(self):
163
165
self .test_unmanaged_missing ()
164
166
165
167
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 )
168
173
def 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
170
182
171
183
172
184
def test_unittest_interaction (django_testdir ):
You can’t perform that action at this time.
0 commit comments