Exemplo n.º 1
0
def test_hookrecorder_basic_no_args_hook():
    rec = HookRecorder(PluginManager())
    apimod = type(os)('api')
    def pytest_xyz():
        "x"
    apimod.pytest_xyz = pytest_xyz
    rec.start_recording(apimod)
    rec.hook.pytest_xyz()
    call = rec.popcall("pytest_xyz")
    assert call._name == "pytest_xyz"
Exemplo n.º 2
0
def test_hookrecorder_basic_no_args_hook():
    rec = HookRecorder(PluginManager())
    apimod = type(os)('api')
    def pytest_xyz():
        "x"
    apimod.pytest_xyz = pytest_xyz
    rec.start_recording(apimod)
    rec.hook.pytest_xyz()
    call = rec.popcall("pytest_xyz")
    assert call._name == "pytest_xyz"
Exemplo n.º 3
0
def test_hookrecorder_basic():
    rec = HookRecorder(PluginManager())
    class ApiClass:
        def pytest_xyz(self, arg):
            "x"
    rec.start_recording(ApiClass)
    rec.hook.pytest_xyz(arg=123)
    call = rec.popcall("pytest_xyz")
    assert call.arg == 123
    assert call._name == "pytest_xyz"
    pytest.raises(pytest.fail.Exception, "rec.popcall('abc')")
Exemplo n.º 4
0
def test_hookrecorder_basic():
    rec = HookRecorder(PluginManager())
    class ApiClass:
        def pytest_xyz(self, arg):
            "x"
    rec.start_recording(ApiClass)
    rec.hook.pytest_xyz(arg=123)
    call = rec.popcall("pytest_xyz")
    assert call.arg == 123
    assert call._name == "pytest_xyz"
    pytest.raises(pytest.fail.Exception, "rec.popcall('abc')")
Exemplo n.º 5
0
def test_hookrecorder_basic(holder) -> None:
    pm = PytestPluginManager()
    pm.add_hookspecs(holder)
    rec = HookRecorder(pm)
    pm.hook.pytest_xyz(arg=123)
    call = rec.popcall("pytest_xyz")
    assert call.arg == 123
    assert call._name == "pytest_xyz"
    pytest.raises(Failed, rec.popcall, "abc")
    pm.hook.pytest_xyz_noarg()
    call = rec.popcall("pytest_xyz_noarg")
    assert call._name == "pytest_xyz_noarg"
Exemplo n.º 6
0
def test_hookrecorder_basic(holder):
    pm = PytestPluginManager()
    pm.add_hookspecs(holder)
    rec = HookRecorder(pm)
    pm.hook.pytest_xyz(arg=123)
    call = rec.popcall("pytest_xyz")
    assert call.arg == 123
    assert call._name == "pytest_xyz"
    pytest.raises(pytest.fail.Exception, rec.popcall, "abc")
    pm.hook.pytest_xyz_noarg()
    call = rec.popcall("pytest_xyz_noarg")
    assert call._name == "pytest_xyz_noarg"
Exemplo n.º 7
0
def test_hookrecorder_basic(holder):
    pm = PluginManager()
    pm.hook._addhooks(holder, "pytest_")
    rec = HookRecorder(pm)
    pm.hook.pytest_xyz(arg=123)
    call = rec.popcall("pytest_xyz")
    assert call.arg == 123
    assert call._name == "pytest_xyz"
    pytest.raises(pytest.fail.Exception, "rec.popcall('abc')")
    pm.hook.pytest_xyz_noarg()
    call = rec.popcall("pytest_xyz_noarg")
    assert call._name == "pytest_xyz_noarg"
Exemplo n.º 8
0
def test_hookrecorder_basic(holder):
    pm = PytestPluginManager()
    pm.addhooks(holder)
    rec = HookRecorder(pm)
    pm.hook.pytest_xyz(arg=123)
    call = rec.popcall("pytest_xyz")
    assert call.arg == 123
    assert call._name == "pytest_xyz"
    pytest.raises(pytest.fail.Exception, "rec.popcall('abc')")
    pm.hook.pytest_xyz_noarg()
    call = rec.popcall("pytest_xyz_noarg")
    assert call._name == "pytest_xyz_noarg"
Exemplo n.º 9
0
def hookrecorder(request, config):
    hookrecorder = HookRecorder(config.pluginmanager)
    if hasattr(hookrecorder, "start_recording"):
        hookrecorder.start_recording(newhooks)
    request.addfinalizer(hookrecorder.finish_recording)
    return hookrecorder
Exemplo n.º 10
0
def hookrecorder(request, config):
    hookrecorder = HookRecorder(config.pluginmanager)
    if hasattr(hookrecorder, "start_recording"):
        hookrecorder.start_recording(newhooks)
    request.addfinalizer(hookrecorder.finish_recording)
    return hookrecorder