Search code examples
shellcommand-linebuildpipelinenose

nosetests skip certain tests in python with multiple tests


I want to skip or exclude some certain tests from the build or the pipeline.

I am running nosetests -s -v * which runs all the tests under some specific folder.

Suppose there are about 30 tests and out of the 5 I want to skip- To do that I am trying

nosetests -s -v * --exclude-test test_sometest.py test_somemoretest.py

or

nosetests -s -v * -- test_sometest.py test_somemoretest.py

but both of them not work for me.

I am referring from here

#!/bin/sh

cd tests/engine_tests/measures

nosetests -s -v * --exclude-test test_sometest1.py test_somemoretest2.py test_sometest3.py test_somemoretest4.py

Any help would be great!!


Solution

  • python -m pytest --cache-clear -v -x -r a --junit-xml=tests/engine_tests --junit-prefix=measure_tests *.py --deselect Test1\.py --deselect Test2\.py --deselect Test3\.py --deselect Test4\.py
    

    I tried this and it worked for me. Before that You need to install pytest

    pip install pytest
    

    Documentation will be find by typing pytest --help under terminal

    or somewhere here