MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_invocation_args

Function test_invocation_args

testing/test_config.py:1795–1819  ·  view source on GitHub ↗

Ensure that Config.invocation_* arguments are correctly defined

(pytester: Pytester)

Source from the content-addressed store, hash-verified

1793
1794
1795def test_invocation_args(pytester: Pytester) -> None:
1796 """Ensure that Config.invocation_* arguments are correctly defined"""
1797
1798 class DummyPlugin:
1799 pass
1800
1801 p = pytester.makepyfile("def test(): pass")
1802 plugin = DummyPlugin()
1803 rec = pytester.inline_run(p, "-v", plugins=[plugin])
1804 calls = rec.getcalls("pytest_runtest_protocol")
1805 assert len(calls) == 1
1806 call = calls[0]
1807 config = call.item.config
1808
1809 assert config.invocation_params.args == (str(p), "-v")
1810 assert config.invocation_params.dir == pytester.path
1811
1812 plugins = config.invocation_params.plugins
1813 assert len(plugins) == 2
1814 assert plugins[0] is plugin
1815 assert type(plugins[1]).__name__ == "Collect" # installed by pytester.inline_run()
1816
1817 # args cannot be None
1818 with pytest.raises(TypeError):
1819 Config.InvocationParams(args=None, plugins=None, dir=Path()) # type: ignore[arg-type]
1820
1821
1822@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 4

DummyPluginClass · 0.85
getcallsMethod · 0.80
makepyfileMethod · 0.45
inline_runMethod · 0.45

Tested by

no test coverage detected