Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for testing unmanaged models (updated) #310

Closed
wants to merge 0 commits into from

Conversation

timb07
Copy link

@timb07 timb07 commented Jan 29, 2016

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.

with connection.schema_editor() as schema:
schema.deferred_sql = []
for model_class in models:
if not hasattr(model, '_meta'):
Copy link

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

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

@blueyed
Copy link
Contributor

blueyed commented Apr 14, 2018

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

@timb07
Copy link
Author

timb07 commented May 26, 2018

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

@halfnibble
Copy link

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
Copy link
Contributor

blueyed commented Jul 26, 2018

@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.

None yet

4 participants