Wie und wo findet py.test Geräte?

Wo und wie sucht py.test nach Fixtures? Ich habe den gleichen Code in 2 Dateien im gleichen Ordner. Wenn ich conftest.py lösche, kann cmdopt nicht gefunden werden, wenn test_conf.py ausgeführt wird (auch im selben Ordner. Warum wird sonoftest.py nicht durchsucht?

# content of test_sample.py
def test_answer(cmdopt):
    if cmdopt == "type1":
        print ("first")
    elif cmdopt == "type2":
        print ("second")
    assert 0 # to see what was printed
Inhalt von conftest.py
import pytest

def pytest_addoption(parser):
    parser.addoption("--cmdopt", action="store", default="type1",
        help="my option: type1 or type2")

@pytest.fixture
def cmdopt(request):
    return request.config.getoption("--cmdopt")
Inhalt von sonoftest.py
import pytest

def pytest_addoption(parser):
    parser.addoption("--cmdopt", action="store", default="type1",
        help="my option: type1 or type2")

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

Die Docs sagen

http://pytest.org/latest/fixture.html#fixture-function

pytest findet das test_ehlo aufgrund des test_-Präfixes. Die Testfunktion benötigt ein Funktionsargument namens smtp. Eine passende Fixture-Funktion wird gefunden, indem nach einer Fixture-markierten Funktion namens smtp gesucht wird.smtp () wird aufgerufen, um eine Instanz zu erstellen.test_ehlo () wird aufgerufen und schlägt in der letzten Zeile der Testfunktion fehl.

Antworten auf die Frage(3)

Ihre Antwort auf die Frage