Page MenuHomeSoftware Heritage

migrate tests from nose to pytest
Closed, MigratedEdits Locked

Description

I'd like to consider the idea of migrating the test set of all the python modules to pytest

It would help for several aspects, especially via the test fixtures mechanism, like make it easier to write tests for things like celery tasks (see celery fixtures for example)

The main problem is that it will most probably require to migrate all tests at once, which seems quite a job.

Update: we've decided to go ahead with this

Related Objects

Mentioned In
D1773: Convert empty author/committer name/email strings to bytes.
D1744: swh.loader.base: Add tests
R65:5468c762651d: tests: Migrate from nose to pytest
R65:65fa46813e76: Add pytest.ini file ignoring node_modules
R65:2591d448ad42: Rename test methods to test_* to allow collection by pytest
rDLDTAR11be0f72e05f: tests: kill remaining nose-isms
rDLDPYf5ed3815b51c: tests: kill remaining nose-isms
rDWAPPS5468c762651d: tests: Migrate from nose to pytest
D616: Migrate from nose to pytest and add tox.ini
rDCIDXad017c83be95: d/rules: Update build with pytest flags
rDCIDX29a19ed8fa86: d/control: Migrate to pytest
D604: Packaging indexer adaptations
rDSCHf326cefe5aea: d/rules: Update build with pytest flags
rDSCHe25fdf732603: d/control: Update pytest build dependency
rDCIDX3eaf0e74e6cd: tests: migrate to pytest
D597: tests: migrate to pytest
rDDEPbd44391cfca5: tests: replace nose with pytest
D592: tests: replace nose with pytest
rDARC01a52bba74c2: tests: migrate to pytest
D582: tests: Add tox.ini and migrate to pytest
D580: tests: migrate to pytest
rDLDPYf070ab290f30: tests: Migrate to pytest
rDLDG2349776e0220: tests: Use pytest's test marker
rDLDG54af337d3811: requirements-test.txt: Update tests requirements to pytest
rDLDDEB31c1cb60b08b: tests: Use pytest's test marker
rDLDDEB881faf685f91: tests: Migrate to pytest
rDLDHGbaf34c93bd4f: tests: Migrate to pytest
rDLDSVNf18899d76f3d: tests: Migrate to pytest
rDLDTAR3505480fbc3f: tests: Migrate to pytest
rDLDDIR3c593a075938: tests: Migrate to pytest
rDLDBASEe3259e9c094c: d/control: Update build dependency
rDLDBASE90d0ed0849b8: requirements-test.txt: Update tests requirements to pytest
rDLDBASEb570b2ce7b36: tests: Use pytest's test marker
D578: Add tox.ini file and migrate to pytest
D577: Add tox.ini file and migrate to pytest
D576: Add tox.ini file and migrate to pytest
D575: Add a tox.ini and migrate to pytest
D573: tests: Add tox.ini file and migrate to pytest
D572: tests: Add tox.ini file and migrate to pytest
D570: swh-loader-dir: Add tox.ini and migrate to pytest
rDWAPPS65fa46813e76: Add pytest.ini file ignoring node_modules
D566: swh-loader-core: Add tox.ini and migrate to pytest
rDSCH80041ad12691: tests: replace nose's attr() by pytest's mark() for tests tagging
rDSCH3e6465790e7a: replace nose by pytest in test requirements and add a simple tox file
rDSTO32ef18253af5: tests: use pytest and add a simple tox file
D553: tests: use pytest and add a simple tox file
D552: replace nose by pytest in test requirements and add a simple tox file
rDOBJSc1c8694af380: tests: use pytest instead of nose in test requirements and add a simple tox file
rDMODb210fddf1459: tests: use pytest instead of nose
D549: tests: use pytest instead of nose and other small test-related stuff
D547: tests: replace remaining nose-isms by pytest
rDLDSVN8715f2e58be9: Rename test methods to test_* to enable collection by pytest
rDLDG802a0bcfbca0: Rename test methods to test_* to enable collection by pytest
rDLDHG897b7648c3d1: Rename test methods to test_* to enable collection by pytest
rDLDPY45c82a817924: Rename test methods to test_* to enable collection by pytest
rDLDTAR6864183a8277: Rename test methods to test_* to enable collection by pytest
rDLDDIRe8f827444663: Rename test methods to test_* to allow collection by pytest
D532: Rename test methods to test_* to enable collection by pytest
rDLDDEB2a213e77c506: Rename test methods to test_ to allow collection by pytest
rDSCH1e371dbcbf54: Rename test methods to test_* to allow collection by pytest
D530: Rename test methods to test_* to allow collection by pytest
rDWAPPS2591d448ad42: Rename test methods to test_* to allow collection by pytest
rDLSb3e815bef8ff: Rename test methods to test_ to allow collection by pytest
rDCIDXc13acb2e660f: Rename test methods to test_* to allow collection by pytest
rDARC5dc8f3df2718: Rename test methods to test_ to allow pytest collection
rDDEP097d262dc7b5: Rename test methods to test_ to allow pytest collection
D529: Rename test methods to test_* to allow collection by pytest
D526: Rename test methods to test_* to allow collection by pytest
D525: Rename test methods to test_ to allow pytest collection
D524: Rename test methods to test_ to allow pytest collection
rDOBJS75b2c56051eb: Rename test methods to test_ to allow py.test collection
rDSTO3a5922908981: Rename test methods to test_* to allow py.test collection
rDLDBASEeaa500ee3edc: Rename test methods to test_* to allow py.test collection
rDMOD7af882adf111: Rename test methods to test_ to allow py.test collection
D523: Rename test methods to test_ to allow py.test collection
D522: Rename test methods to test_* to allow py.test collection
D521: Rename test methods to test_* to allow py.test collection
D520: Rename test methods to test_ to allow py.test collection
rDCOREddba92bd1ffc: Use the test_* method name convention rather than nose.tools.istest
D516: Use the test_* method name convention rather than nose.tools.istest
Mentioned Here
D516: Use the test_* method name convention rather than nose.tools.istest

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

I've submitted D516 as a showcase of a testsuite migration that would allow running pytest on swh.core

nice regexp-fu. We just have to make sure "grep 'istest'" doesn't return anything afterward

No objections here either.

All tests in our unittest.TestCases are now named test_$something, which allows them to be picked up by pytest.

I've added a few missing tests/__init__.py files as well.

Running python3 -m pytest in all repositories seems to do a thing. In most cases the thing is even correct, and the tests are running (and successful).

The last nose-specific feature we're using is the @attr decorator, that is being used to mark tests that require a database, or stuff from swh-storage-testdata (so that they can be skipped, f.e. when building Debian packages). This can likely be replaced with a pytest mark instead.

zack renamed this task from Discuss the opportunity of migrating tests to pytest to migrate tests from nose to pytest.Oct 15 2018, 3:14 PM
zack raised the priority of this task from Wishlist to Normal.
zack updated the task description. (Show Details)

(i've retitled this according to consensus)

adding another todo list item for completing this: Makefile.python in swh-environment should be migrated from nose to pytest

olasd reopened this task as Work in Progress.Oct 23 2018, 5:30 PM

The closure was a lie