Closed AaronV77 closed 5 years ago
Hi @AaronV77,
I think the easiest way to accomplish the same thing is to create your own mark, say pytest.mark.slow
:
@pytest.mark.slow
def test_add_datasets(api, catalog_entry):
...
And then you can skip those tests by running -m "not slow"
, no additional code required.
@nicoddemus Thank you for the quick response. Is there anyway to provide more than one argument for the -m option? Lets say if I have a two groups of test to run, I've tried the following:
pytest test -s -m slow download
pytest test -s -m slow -m download
. Neither of these work, and possible way? Thanks
You can use and
, not
, and or
operators: pytest test -s -m "slow and download"
@nicoddemus just actually found that! When I run it though it deselects those two test, instead of only running those two tests?
It selects the tests with those marks. If you don't want to run the tests, you can use not
:
pytest test -s -m "not slow and not download"
I know that, but what I'm trying to say is that the following command pytest test -s -m "slow and download"
is not in fact running the test with the selected marks.
import pytest
pytest.mark.print
def test_printing():
print("Something-1")
@pytest.mark.print2
def test_printing2():
print("Something-2")
def test_printing3():
print("Something-3")
def test_printing4():
print("Something-4")
Command pytest test -s
:
(quest-py3.6-DEV) AaronV77:pytest AaronV77$ pytest test -s
==========================================================================test session starts ==========================================================================
platform darwin -- Python 3.6.6, pytest-3.8.2, py-1.6.0, pluggy-0.7.1
rootdir: /Users/AaronV77/Documents/pytest, inifile: pytest.ini
plugins: cov-2.6.0, nbval-0.9.1
collected 4 items
test/test_anything.py Something-1
.Something-2
.Something-3
.Something-4
.
==========================================================================4 passed in 0.02 seconds ==========================================================================
Command pytest test -s -m print
:
(quest-py3.6-DEV) AaronV77:pytest AaronV77$ pytest test -s -m print
==========================================================================test session starts ==========================================================================
platform darwin -- Python 3.6.6, pytest-3.8.2, py-1.6.0, pluggy-0.7.1
rootdir: /Users/AaronV77/Documents/pytest, inifile: pytest.ini
plugins: cov-2.6.0, nbval-0.9.1
collected 4 items / 3 deselected
test/test_anything.py Something-1
.
==========================================================================1 passed, 3 deselected in 0.01 seconds ==========================================================================
Command pytest test -s -m print2
:
(quest-py3.6-DEV)AaronV77:pytest AaronV77$ pytest test -s -m print2
========================================================================== test session starts ==========================================================================
platform darwin -- Python 3.6.6, pytest-3.8.2, py-1.6.0, pluggy-0.7.1
rootdir: /Users/AaronV77/Documents/pytest, inifile: pytest.ini
plugins: cov-2.6.0, nbval-0.9.1
collected 4 items / 3 deselected
test/test_anything.py Something-2
.
==========================================================================1 passed, 3 deselected in 0.01 seconds ==========================================================================
Command `pytest test -s -m "print and print2':
(quest-py3.6-DEV) AaronV77:pytest AaronV77$ pytest test -s -m "print and print2"
==========================================================================test session starts ==========================================================================
platform darwin -- Python 3.6.6, pytest-3.8.2, py-1.6.0, pluggy-0.7.1
rootdir: /Users/AaronV77/Documents/pytest, inifile: pytest.ini
plugins: cov-2.6.0, nbval-0.9.1
collected 4 items / 4 deselected
==========================================================================4 deselected in 0.04 seconds ==========================================================================
Command `pytest test -s -m "not print and not print2':
(quest-py3.6-DEV) AaronV77:pytest AaronV77$ pytest test -s -m "not print and not print2"
==========================================================================test session starts ==========================================================================
platform darwin -- Python 3.6.6, pytest-3.8.2, py-1.6.0, pluggy-0.7.1
rootdir: /Users/AaronV77/Documents/pytest, inifile: pytest.ini
plugins: cov-2.6.0, nbval-0.9.1
collected 4 items / 2 deselected
test/test_anything.py Something-3
.Something-4
.
==========================================================================2 passed, 2 deselected in 0.01 seconds ==========================================================================
@nicoddemus Never mind I understand now how the and
, and the or
works. In my mind I thought it would run all the tests that were marked with either print or print2, but in reality the test is only ran if it is marked with both print and print2. Sorry for the confusion.
Can one of you give me a hint on how to fix that issue on https://github.com/ansible/molecule/blob/master/test/conftest.py#L114 ? Thanks.
@ssbarnea sorry for the delay. Can you provide a link for a failing build?
Hello,
Issue Summary: I've ran into the issue of the following line
pytest.config.getoption
no longer being supported in the 3.8.2 conda package of pytest. So the issue that I am having is how to transition from using the following below to using the standardrequest.config.getoption("--skip-slow")
. I'm seeing a lot of documentation inconsistencies and don't know how to go about fixing this; other than:Thanks for any help!
Environment Listing:
Operating System Version: