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

Tests are skipped #148

Closed
SaturnFromTitan opened this issue Nov 23, 2020 · 7 comments
Closed

Tests are skipped #148

SaturnFromTitan opened this issue Nov 23, 2020 · 7 comments

Comments

@SaturnFromTitan
Copy link

SaturnFromTitan commented Nov 23, 2020

Hi, I just wanted to give this project a go as I want to run a rather complex data migration.

However, as soon as I add the migrator fixture to my test case it's being skipped.

@pytest.mark.django_db
def test_datamig(migrator):
    pass

This is the test output I get:

Test session starts (platform: linux, Python 3.8.4, pytest 5.4.3, pytest-sugar 0.9.4)
cachedir: .pytest_cache
django: settings: xyz.settings (from option)
rootdir: /code, inifile: setup.cfg
plugins: django-test-migrations-1.0.0, xdist-1.34.0, celery-4.4.7, sugar-0.9.4, django-3.9.0, mock-3.3.0, Faker-4.1.2, socket-0.3.5, cov-2.10.1, forked-1.3.0
[gw0] linux Python 3.8.4 cwd: /code/sales_cockpit_be
[gw0] Python 3.8.4 (default, Jul 14 2020, 02:56:59)  -- [GCC 8.3.0]
gw0 [1]
scheduling tests via LoadScheduling

xyz/tests/test_migration.py::test_datamig s           100% ██████████
[gw0] SKIPPED xyz/tests/test_migration.py 

Results (14.02s):

       1 skipped

I also tried creating migrator manually inside the test with migrator = Migrator() or migrator_factory, but the issue persists.

I use the 1.0.0 version.

Does any1 have an idea what the reason could be?

@sobolevn
Copy link
Member

Can you please show your outout for running only this test?

@SaturnFromTitan
Copy link
Author

SaturnFromTitan commented Nov 23, 2020

I added it to the issue description in the top @sobolevn

When I remove the migrator fixture, the test isn't skipped btw

@sobolevn
Copy link
Member

Is this the case? https://github.com/wemake-services/django-test-migrations/blob/master/django_test_migrations/contrib/pytest_plugin.py#L62

@sobolevn
Copy link
Member

Or it might the custom marker we add to all tests: https://github.com/wemake-services/django-test-migrations/blob/master/django_test_migrations/contrib/pytest_plugin.py#L28 Might be that it is ignored.

@SaturnFromTitan
Copy link
Author

When running pytest xyz/tests/test_migration.py::test_datamig -vv -m migration_test the test is deselected instead:

Test session starts (platform: linux, Python 3.8.4, pytest 5.4.3, pytest-sugar 0.9.4)
cachedir: .pytest_cache
django: settings: xyz.settings (from option)
rootdir: /code, inifile: setup.cfg
plugins: django-test-migrations-1.0.0, xdist-1.34.0, celery-4.4.7, sugar-0.9.4, django-3.9.0, mock-3.3.0, Faker-4.1.2, socket-0.3.5, cov-2.10.1, forked-1.3.0
collecting ... 

Results (0.13s):
       1 deselected

I think the marker was only introduced after the 1.0.0 release and isn't public yet (I installed via pip, not the current master).


Your first guess seems to be right though. When using the -rs flag it says SKIPPED [1] /usr/local/lib/python3.8/site-packages/django_test_migrations/contrib/pytest_plugin.py:39: --nomigrations was specified

However, the test above was just a minimal example. My actual test looks more like this:

@pytest.mark.django_db
def test_datamig(migrator):
    old_state = migrator.apply_initial_migration(('campaigns', '0011_adjust_campaign_headerdiscountpercent'))
    CampaignLine = old_state.apps.get_model('campaigns', 'CampaignLine')
    cl = CampaignLine.objects.create(netClientBudget=1000)

    new_state = migrator.apply_tested_migration(('campaigns', '0012_fix_campaignline_netclientbudget'))
    CampaignLine = new_state.apps.get_model('campaigns', 'CampaignLine')
    cl = CampaignLine.objects.get(pk=cl.id)
    assert cl.netClientBudget == 1200

    migrator.reset()

The test is still skipped with the same skip message though:

Test session starts (platform: linux, Python 3.8.4, pytest 5.4.3, pytest-sugar 0.9.4)
cachedir: .pytest_cache
django: settings: xyz.settings (from option)
rootdir: /code, inifile: setup.cfg
plugins: django-test-migrations-1.0.0, xdist-1.34.0, celery-4.4.7, sugar-0.9.4, django-3.9.0, mock-3.3.0, Faker-4.1.2, socket-0.3.5, cov-2.10.1, forked-1.3.0
collecting ... 
 xyz/campaigns/tests/test_migrations.py::test_datamig s                                      100% ██████████
========================================================================================== short test summary info ==========================================================================================
SKIPPED [1] /usr/local/lib/python3.8/site-packages/django_test_migrations/contrib/pytest_plugin.py:39: --nomigrations was specified

Results (4.70s):
       1 skipped

@stefanitsky
Copy link

Is this the case? https://github.com/wemake-services/django-test-migrations/blob/master/django_test_migrations/contrib/pytest_plugin.py#L62

Thanks! Removing "--nomigrations" from setup.cfg -> [tool:pytest] -> addopts helped me. @SaturnFromTitan check your pytest config for default addopts.

@SaturnFromTitan
Copy link
Author

Ah of course 🤦

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

No branches or pull requests

3 participants