Skip to content

Add support for testing unmanaged models (updated) - #310

Closed
timb07 wants to merge 0 commit into
pytest-dev:masterfrom
timb07:master
Closed

Add support for testing unmanaged models (updated)#310
timb07 wants to merge 0 commit into
pytest-dev:masterfrom
timb07:master

Conversation

@timb07

@timb07 timb07 commented Jan 29, 2016

Copy link
Copy Markdown

As noted in ojake's PR #270 (which was created to address #264), the issue with the implementation of the pytest.mark.django_use_model mark that caused tests not to be collected can be fixed relatively easily by supplying the model argument as a kwarg. (I'm not very familiar with pytest, so there may be a better way of fixing this issue.)

This PR includes:

  • ojake's django_use_model implementation from Add support for testing unmanaged models #270, modified with…
  • the necessary changes for the fix noted above;
  • removal of the contextlib.closing() wrapper around connection.schema_editor() (which isn't necessary and doesn't work anyway);
  • addition of a check for the existence of django.db.connection.schema_editor before the relevant tests in test_database.py, so the tests are skipped for Django < 1.7.

Comment thread pytest_django/plugin.py Outdated
with connection.schema_editor() as schema:
schema.deferred_sql = []
for model_class in models:
if not hasattr(model, '_meta'):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be model_class ?

@halfnibble

Copy link
Copy Markdown

What needs to be done to make this a reality? Does anyone want help on this?

@blueyed

blueyed commented Apr 14, 2018

Copy link
Copy Markdown
Contributor

@halfnibble
I guess you could pick up the branch behind this PR and finish it in a new PR.

@timb07

timb07 commented May 26, 2018

Copy link
Copy Markdown
Author

The new PR has problems with mysql; can anyone help? @halfnibble?

@halfnibble

Copy link
Copy Markdown

Yes. I think I will take a look at this. We use MySQL in production, so supporting it is important!

Numerico added a commit to Numerico/pytest-django that referenced this pull request Jun 10, 2018
Numerico added a commit to Numerico/medios_bot that referenced this pull request Jun 10, 2018
wordpress unmanaged models needs django_use_model marker
see pytest-dev/pytest-django#310
Numerico added a commit to Numerico/medios_bot that referenced this pull request Jun 10, 2018
wordpress unmanaged models needs django_use_model marker
see pytest-dev/pytest-django#310
@blueyed

blueyed commented Jul 26, 2018

Copy link
Copy Markdown
Contributor

@halfnibble
Please take a look at the MySQL related failures in #600 then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants