mardi 1 janvier 2019

PyTest not discovering new test module, but changes made in old test modules are reflected in execution

I am writing tests for an app using PyTest, and had three test modules as of this evening. They work as expected, and any changes I make to them are reflected in the test execution (I intentionally put incorrect assertions to be completely sure). However, I added a new module this evening (which also begins with test_ and does not contain a class (so this SO answer does not apply), it is in fact almost identical in structure to one other test module) and no matter what I do PyTest refuses to discover it. I am using VS Code for development, but I tried running pytest from the terminal as well, to the same effect.

This issue on GitHub suggested I try rm -rf .cache which solved nothing. I tried removing all my __pycache__ files just to be safe as well as the .pytest_cache file, to no avail. I do not get any errors, in particular test_grader.py, test_misc.py and test_solution_optimal.py work perfectly fine. Here is proof haha. test_solution_student.py is an exact copy of test_solution_optimal.py with a few deliberately incorrect assertions, but pytest won't discover it no matter what I do.

I only enabled pytest as recommended here and the autoTestDiscover.... is enabled as well. However since running pytest from the terminal does not result in the discovery of the last module either I doubt it's an issue with my VS code settings file.

Directory structure:

Top-Level Directory
├── .pytest_cache
│   └── v
├── Grader
│   ├── (Several files to be tested)
│   ├── __init__.py
│   └── __pycache__
├── __pycache__
│   └── globals_store.cpython-37.pyc
├── graphs
│   ├── (Additional irrelevant files)
├── tests
│   ├── __pycache__
│   ├── test_grader.py
│   ├── test_misc.py
│   ├── test_solution_optimal.py
│   └── test_solution_student.py
└── venv
    ├── bin
    ├── include
    ├── lib
    └── share

I run pytest from the Top-Level Directory.

If somebody could give me a lead on what else I could try that might result in the test module being discovered I would forever be in your debt.

Aucun commentaire:

Enregistrer un commentaire