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

Method test_attributes

testing/python/metafunc.py:995–1023  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

993
994class TestMetafuncFunctional:
995 def test_attributes(self, pytester: Pytester) -> None:
996 p = pytester.makepyfile(
997 """
998 # assumes that generate/provide runs in the same process
999 import sys, pytest
1000 def pytest_generate_tests(metafunc):
1001 metafunc.parametrize('metafunc', [metafunc])
1002
1003 @pytest.fixture
1004 def metafunc(request):
1005 return request.param
1006
1007 def test_function(metafunc, pytestconfig):
1008 assert metafunc.config == pytestconfig
1009 assert metafunc.module.__name__ == __name__
1010 assert metafunc.function == test_function
1011 assert metafunc.cls is None
1012
1013 class TestClass(object):
1014 def test_method(self, metafunc, pytestconfig):
1015 assert metafunc.config == pytestconfig
1016 assert metafunc.module.__name__ == __name__
1017 unbound = TestClass.test_method
1018 assert metafunc.function == unbound
1019 assert metafunc.cls == TestClass
1020 """
1021 )
1022 result = pytester.runpytest(p, "-v")
1023 result.assert_outcomes(passed=2)
1024
1025 def test_two_functions(self, pytester: Pytester) -> None:
1026 p = pytester.makepyfile(

Callers

nothing calls this directly

Calls 3

assert_outcomesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected