Pytest-django: Support testing migrations in tests

Created on 8 May 2018  路  5Comments  路  Source: pytest-dev/pytest-django

As in this gist: https://gist.github.com/blueyed/4fb0a807104551f103e6 , it would be great to get this as part of pytest-django, or otherwise as a separate plugin.

@TauPan 's fork of my fixture gist worked pretty good for me in latest Django: https://gist.github.com/TauPan/aec52e398d7288cb5a62895916182a9f

Some things that are broken or unsupported that would be nice to have (or at least need to be documented if we include this "as is"):

  • No support for capturing exceptions during migration with pytest.raises
  • Detecting and updating settings.MIGRATION_MODULES for a migration test
  • No support for factoryboy (of course)

This ticket is mainly for discussing better ways of testing django data migrations in pytest.

Most helpful comment

Hi :wave:
I am already working on similar package for testing Django's migrations:

https://github.com/skarzi/django-test-migrations

It's still in progress, because I am struggling with some issues, for instance this listed in issue description, but I will be really grateful for any suggestions and help from anyone

All 5 comments

This is actually a very nice feature, that was started by @blueyed some years ago. What about trying to include this to pytest-django?

Hi :wave:
I am already working on similar package for testing Django's migrations:

https://github.com/skarzi/django-test-migrations

It's still in progress, because I am struggling with some issues, for instance this listed in issue description, but I will be really grateful for any suggestions and help from anyone

@skarzi have you seen https://pypi.org/project/django-test-migrations?
I think it has a bit more pytesty api...
It would be cool to have it as a part of standard pyetst-django imho

I haven't seen this project, but it's almost identical, so we can use it if you guys prefer :+1:

I think I'm going to switch to using django-test-migrations instead of maintaining my own migrator fixture; and thus can close this issue. Please feel free to reopen if there is more to discuss in relation to pytest-django.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ojake picture ojake  路  6Comments

clintonb picture clintonb  路  4Comments

koxu1996 picture koxu1996  路  3Comments

dan-passaro picture dan-passaro  路  4Comments

mpasternak picture mpasternak  路  5Comments