Questions tagged [pytest-markers]

7 questions
16
votes
3 answers

PytestUnknownMarkWarning: Unknown pytest.mark.xxx - is this a typo?

I have a file called test.py with the following code: import pytest @pytest.mark.webtest def test_http_request(): pass class TestClass: def test_method(self): pass pytest -s test.py passed but gave the following warnings: pytest…
Jonathan L
  • 6,404
  • 3
  • 39
  • 30
3
votes
1 answer

Run pytest markers based on command line argument

I have a python file that reads from a configuration file and initializes certain variables, followed by a number of test cases, defined by pytest markers. I run different set of test cases parallelly by calling these markers, like this - pytest -m…
loney61411
  • 35
  • 2
3
votes
1 answer

pytest: is it possible to enable a marker from code?

It is possible to only run tests marked by a certain marker by using the -m argument when calling pytest. e.g. pytest -m testsubset_a. I wonder... is it also possible to enable one of these markers from inside the code? e.g. somewhere during…
Opifex
  • 329
  • 2
  • 12
2
votes
1 answer

Run tests with a set of marks, which selected based on command line parameter's value

I have following tests: @pytest.mark.hardware @pytest.mark.feature1 @pytest.mark.feature2 def test_device1(): pass @pytest.mark.hardware @pytest.mark.feature1 def test_device2(): pass @pytest.mark.hardware @pytest.mark.feature2 def…
Maria
  • 88
  • 6
1
vote
1 answer

How to skip tests based on condition in pytest?

Below is the snippet of conftest.py, which accepts command line arguments. conftest.py import sys,json,pytest import logging def tear_down(): logging.info(" tear-down after all tests") def pytest_addoption(parser): …
StackGuru
  • 421
  • 3
  • 16
0
votes
0 answers

Can we run multiple marker in parallel?

I have a python script and say I have 10 test cases in it. 5 are part of marker1 and another 5 are part of marker2. I want to start 2 threads in parallel so marker1 tests can run in 1 thread and marker2 tests can run in another. And my execution…
0
votes
0 answers

pytest - run tests with customized markers

I used customized pytest markers like below, @pytest.mark.test_id("AB-1234") def test_test1(): pass @pytest.mark.test_id("AB-1234") def test_test2(): pass @pytest.mark.test_id("AB-5678") def test_test3(): pass Here test_id is the…
VishnuM
  • 23
  • 5