conftest.py 1006 B

123456789101112131415161718192021222324
  1. import pytest
  2. # https://docs.pytest.org/en/6.2.x/example/simple.html?highlight=addoption#pass-different-values-to-a-test-function-depending-on-command-line-options
  3. def pytest_addoption(parser):
  4. parser.addoption('--translator', action='store', default=None, help='Chosen translator for test run')
  5. parser.addoption('--target-lang', action='store', default='ENG', help='Target language for translator test run')
  6. parser.addoption('--text', action='store', default=None, help='Text to be used for translation test run')
  7. parser.addoption('--count', action='store', type=int, default=1, help='Amount of times the test should be repeated')
  8. @pytest.fixture
  9. def translator(request):
  10. return request.config.getoption('--translator')
  11. @pytest.fixture
  12. def tgt_lang(request):
  13. return request.config.getoption('--target-lang')
  14. @pytest.fixture
  15. def text(request):
  16. return request.config.getoption('--text')
  17. @pytest.fixture
  18. def count(request):
  19. return request.config.getoption('--count')