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

Method test_parametrize_ids_exception

testing/python/metafunc.py:566–589  ·  view source on GitHub ↗

:param pytester: the instance of Pytester class, a temporary test directory.

(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

564 assert result == [expected]
565
566 def test_parametrize_ids_exception(self, pytester: Pytester) -> None:
567 """
568 :param pytester: the instance of Pytester class, a temporary
569 test directory.
570 """
571 pytester.makepyfile(
572 """
573 import pytest
574
575 def ids(arg):
576 raise Exception("bad ids")
577
578 @pytest.mark.parametrize("arg", ["a", "b"], ids=ids)
579 def test_foo(arg):
580 pass
581 """
582 )
583 result = pytester.runpytest()
584 result.stdout.fnmatch_lines(
585 [
586 "*Exception: bad ids",
587 "*test_foo: error raised while trying to determine id of parameter 'arg' at position 0",
588 ]
589 )
590
591 def test_parametrize_ids_returns_non_string(self, pytester: Pytester) -> None:
592 pytester.makepyfile(

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected