2015-07-20 19 views
5

Mam katalog projektu wygląda popy.test: error: nierozpoznane argumenty

Projects/ 
....this_project/ 
........this_project/ 
............__init__.py 
............code.py 
............tests/ 
................conftest.py 
................test_1.py 
................test_2.py 

i dodałem opcję wiersza poleceń (--PALLADIUM_CONFIG) umieszczając następujące kody do conftest.py

def pytest_addoption(parser): 
    parser.addoption("--PALLADIUM_CONFIG", action="store") 

@pytest.fixture 
def PALLADIUM_CONFIG(request): 
    return request.config.getoption("--PALLADIUM_CONFIG") 

I co dziwne:

gdybym cd do

Projects/this_project/this_project 

lub

Projects/this_project/this_project/tests 

i uruchomić

py.test --PALLADIUM_CONFIG=*** 

jeśli działa dobrze

ale gdybym znaleźć się w na przykład

Projects/this_project 

lub

Projects 

następnie pytest daje mi błąd

py.test: error: unrecognized arguments: --PALLADIUM_CONFIG=*** 

Odpowiedz

4

to ograniczenie samego pytest. Spójrz na docs:

Note that pytest does not find conftest.py files in deeper nested sub directories at tool startup. It is usually a good idea to keep your conftest.py file in the top level test or project root directory.

Jednym z rozwiązań jest stworzenie wtyczki zewnętrznego lub przenieść opcję do pliku bliższej nasady conftest.

Powiązane problemy