Skip to content

Commit a0e3450

Browse files
Jakub Owczarskitimb07
Jakub Owczarski
authored andcommitted
created django_use_model marker for testing unmanaged models;
cherry-picked from d466743
1 parent 8ab968d commit a0e3450

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

pytest_django/plugin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,15 @@ def _django_use_model(request):
418418
else:
419419
models = (model,)
420420

421-
with connection.schema_editor() as schema:
421+
with contextlib.closing(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 connection.schema_editor() as schema:
429+
with contextlib.closing(connection.schema_editor()) as schema:
430430
for model_class in models:
431431
schema.delete_model(model_class)
432432

tests/test_database.py

-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ 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")
146144
@pytest.mark.django_db
147145
class TestUseModel:
148146
"""Tests for django_use_model marker"""

0 commit comments

Comments
 (0)