My problem is that py.test ignoring few tests that having marks (@pytest.mark.some_mark).
I have a folder named featureapp that contain 2 python files:
example_test.py and zapp_sanity.py.
Each python file contains few classes with few tests inside, in addition each file has 1 class that has the pytest mark of: @pytest.mark.zapp_sanity
My terminal command line for running the tests is:
py.test feature_app/ -m "zapp_sanity" -v -s --basetemp=. --color=yes
Actual Results for the run is that only the tests classes in example_test.py are executed and the tests in file zapp_sanity.py are ignored
In addition, I also tried giving to each of the different classes in the different files, a different marks:
@pytest.mark.zapp_2
@pytest.mark.zapp_1
And then running this line:
py.test feature_app/ -m "zapp_1 or zapp_2" -v -s --basetemp=. --color=yes
But it did not work :(
pytest:
This is pytest version 3.3.2, imported from /Library/Python/2.7/site-packages/pytest.pyc
python:
Python 2.7.10
OS:
Mac
pip list:
Package Version
altgraph 0.10.2
Appium-Python-Client 0.24
atlassian-jwt 1.8.1
attrs 17.4.0
awscli 1.11.178
backports-abc 0.5
bdist-mpkg 0.5.0
bonjour-py 0.3
botocore 1.7.36
certifi 2017.7.27.1
cffi 1.11.5
chardet 3.0.4
click 6.7
colorama 0.3.7
configparser 3.5.0
cryptography 1.7.2
DBUtils 1.2
decorator 4.3.0
defusedxml 0.5.0
docutils 0.14
enum 0.4.6
enum34 1.1.6
funcsigs 1.0.2
future 0.16.0
futures 3.1.1
greenlet 0.4.12
idna 2.6
ipaddress 1.0.21
jira 1.0.11
jmespath 0.9.3
json-rpc 1.10.3
jwt 0.5.2
macholib 1.5.1
matplotlib 1.3.1
modulegraph 0.10.4
munch 2.2.0
nose 1.3.7
numpy 1.8.0rc1
oauthlib 2.0.6
ordereddict 1.1
pbr 3.1.1
perfecto 2.0.0.1
Pillow 5.0.0
pip 18.1
pkginfo 1.4.2
pluggy 0.6.0
py 1.5.2
py2app 0.7.3
pyasn1 0.3.7
pycparser 2.18
PyJWT 1.6.1
PyMySQL 0.8.0
pyobjc-core 2.5.1
pyobjc-framework-Accounts 2.5.1
pyobjc-framework-AddressBook 2.5.1
pyobjc-framework-AppleScriptKit 2.5.1
pyobjc-framework-AppleScriptObjC 2.5.1
pyobjc-framework-Automator 2.5.1
pyobjc-framework-CFNetwork 2.5.1
pyobjc-framework-Cocoa 2.5.1
pyobjc-framework-Collaboration 2.5.1
pyobjc-framework-CoreData 2.5.1
pyobjc-framework-CoreLocation 2.5.1
pyobjc-framework-CoreText 2.5.1
pyobjc-framework-DictionaryServices 2.5.1
pyobjc-framework-EventKit 2.5.1
pyobjc-framework-ExceptionHandling 2.5.1
pyobjc-framework-FSEvents 2.5.1
pyobjc-framework-InputMethodKit 2.5.1
pyobjc-framework-InstallerPlugins 2.5.1
pyobjc-framework-InstantMessage 2.5.1
pyobjc-framework-LatentSemanticMapping 2.5.1
pyobjc-framework-LaunchServices 2.5.1
pyobjc-framework-Message 2.5.1
pyobjc-framework-OpenDirectory 2.5.1
pyobjc-framework-PreferencePanes 2.5.1
pyobjc-framework-PubSub 2.5.1
pyobjc-framework-QTKit 2.5.1
pyobjc-framework-Quartz 2.5.1
pyobjc-framework-ScreenSaver 2.5.1
pyobjc-framework-ScriptingBridge 2.5.1
pyobjc-framework-SearchKit 2.5.1
pyobjc-framework-ServiceManagement 2.5.1
pyobjc-framework-Social 2.5.1
pyobjc-framework-SyncServices 2.5.1
pyobjc-framework-SystemConfiguration 2.5.1
pyobjc-framework-WebKit 2.5.1
pyOpenSSL 0.13.1
pyparsing 2.0.1
pyperclip 1.6.4
pytest 3.3.2
python-dateutil 2.6.1
python-jsonrpc 0.10.0
pytz 2013.7
PyYAML 3.12
requests 2.18.4
requests-oauthlib 0.8.0
requests-toolbelt 0.8.0
retry 0.9.2
rsa 3.4.2
s3transfer 0.1.11
scipy 0.13.0b1
selenium 3.6.0
setuptools 18.5
singledispatch 3.4.0.3
singleton 0.1.0
six 1.11.0
svgwrite 1.1.12
termcolor 1.1.0
testrail 0.3.10
tornado 4.5.3
tqdm 4.23.3
Tree 0.2.3
twine 1.11.0
typing 3.5.3.0
UNKNOWN 0.0.0
urllib3 1.22
virtualenv 15.1.0
web.py 0.38
wheel 0.30.0
ws4py 0.4.2
xattr 0.6.4
zapi 0.0.8
pytest by default doesn't look for tests in files not named like test_*.py
also using --basetemp=. actually does a rm -rf . so that's def not a good idea, we should warn about that
Thanks @RonnyPfannschmidt,
Matter of fact the tests that did executed successfully were the ones in example_test.py,
anyway I renamed example_test.py to be example.py and now none of the tests run:
=============================================================== no tests ran in 0.02 seconds ================================================================
@RonnyPfannschmidt, ok!
I just read again you answer,
I renamed my files to be:
test_zapp_sanity.py
test_example.py
and my problem solved!
:)
we can close the ticket, * the solution is to have the prefix of test_ for each python file **, like you said
Most helpful comment
@RonnyPfannschmidt, ok!
I just read again you answer,
I renamed my files to be:
test_zapp_sanity.py
test_example.py
and my problem solved!
:)
we can close the ticket, * the solution is to have the prefix of test_ for each python file **, like you said