4

This is the path to the project

D:\QA\test-framework\python-client

This is a test frame work implemented by python

This is the python file that contains tests

This is the path to the test case that I need to run

D:\QA\test-framework\python-client\test_data\tests\curve.json

This is the beginning of the curve.json file.

 {

"Sklearn - Sklearn - Regression - Curve M2" : [
    {
        "dataImport": {
            "
            "
            "


]

}

This is the tox.ini file

[tox]
envlist = py38

[testenv]
deps =
    pytest
    pytest-html
    pytest-sugar
    pytest-logger
    allure-pytest
    pytest-xdist
    pytest_steps
    datetime
    oauth2client
    gspread
    aiclub
commands = 
    pytest -s -v -k _workflow  --html=test_report.html --alluredir=allure- 
    results/ -n auto --dist=loadfile 
    allure serve allure-results
    pytest {posargs}

I need to run only this curve.json using tox command

snow
  • 55
  • 1
  • 1
  • 11
  • Can you show us the code of `test_pytest.py`? And please include your tox configuration (tox.ini)! – Jürgen Gmach Apr 26 '21 at 17:40
  • @J.G. Those files are attached now – snow Apr 26 '21 at 18:16
  • Usually, in order for `pytest` to find and run your tests, you either have to follow `pytest`s naming scheme, see https://docs.pytest.org/en/reorganize-docs/new-docs/user/naming_conventions.html or you have to create a configuration with your own naming scheme. I do not see that you have any `test_xxx` function in your code. – Jürgen Gmach Apr 26 '21 at 19:56
  • 5
    **tox -e py38 -- project/tests/test_file.py::TestClassName::test_method** – snow Apr 27 '21 at 02:15
  • @J.G. How can I use above format to my project – snow Apr 27 '21 at 02:17
  • I cannot give you an answer when I do not know which of your functions is a test - as I mentioned above (and linked to the documentation), you need to name your test as `def test_something`. Please read the linked documentation. – Jürgen Gmach Apr 27 '21 at 08:50

1 Answers1

1

The easiest way is to use -k option with a string that contains an expression that matches all tests you need to run e.g.

tox -e py38 -- -k "test_first_function or test_another_function"

KindOfGuy
  • 3,081
  • 5
  • 31
  • 47