Page MenuHomePhabricator

Pywikibot pytest should be ready to use
Closed, ResolvedPublicFeature

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

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' ?

Dvorapa triaged this task as Medium priority.Apr 3 2020, 4:36 PM
Dvorapa changed the subtype of this task from "Task" to "Feature Request".

This seems like a good idea. We use some configuration options in both .travis.yml and .appveyor.yml. These should be moved to tests module directly

Change 832451 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [IMPR] Ability to set PYWIKIBOT_TEST_... environment variables wit pwb wrapper

https://gerrit.wikimedia.org/r/832451

Change 832451 merged by Xqt:

[pywikibot/core@master] [IMPR] Ability to set PYWIKIBOT_TEST_... environment variables with pwb wrapper

https://gerrit.wikimedia.org/r/832451