Page MenuHomePhabricator

Pywikibot pytest should be ready to use
Open, Needs TriagePublic

Description

I am currently attempting to get more tests to run with pytest and think we need to make it more convenient to use pytest. Ideally all tests should run after cloning the repository without any further setup.

By default most tests will skip because they involve editing test.wikidata.org. So instead of just typing

$ pytest tests/wikibase_edit_tests.py

the user needs to pass the correct environment variable:

$ ENV_NAME='testing' PYWIKIBOT2_TEST_WRITE=1 python3 -m pytest tests/wikibase_edit_tests.py

But even then the tests run painfully slow, because the bot will use the sleep times in the user-config instead of using lower sleep-times for testing. So it would also be good to make separate settings when running tests (Setting minthrottle = 0, maxthrottle = 1 in the user-config made the tests run in a reasonable time).

For those people that would like to help with the pytest compatibility, just choose a group of tests and run:

$ ENV_NAME='testing' PYWIKIBOT2_TEST_WRITE=1 python3 -m pytest tests/wikibase_edit_tests.py -rxs --maxfail=1

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Zppix, Aklapper. · View Herald TranscriptJul 9 2016, 12:44 PM
Tobias1984 updated the task description. (Show Details)Jul 9 2016, 12:47 PM
jayvdb added a subscriber: jayvdb.EditedJul 9 2016, 6:27 PM

We have at least one customised config variables for the tests, set in tests/__init__.py . Setting throttles in there would also be useful.

More documentation in tests/README.rst very welcome..

what is ENV_NAME='testing' ?