(self, pytester: Pytester)
| 101 | assert passed == skipped == 0 |
| 102 | |
| 103 | def test_broken_repr(self, pytester: Pytester) -> None: |
| 104 | p = pytester.makepyfile( |
| 105 | """ |
| 106 | import pytest |
| 107 | |
| 108 | class reprexc(BaseException): |
| 109 | def __str__(self): |
| 110 | return "Ha Ha fooled you, I'm a broken repr()." |
| 111 | |
| 112 | class BrokenRepr1(object): |
| 113 | foo=0 |
| 114 | def __repr__(self): |
| 115 | raise reprexc |
| 116 | |
| 117 | class TestBrokenClass(object): |
| 118 | def test_explicit_bad_repr(self): |
| 119 | t = BrokenRepr1() |
| 120 | with pytest.raises(BaseException, match="broken repr"): |
| 121 | repr(t) |
| 122 | |
| 123 | def test_implicit_bad_repr1(self): |
| 124 | t = BrokenRepr1() |
| 125 | assert t.foo == 1 |
| 126 | |
| 127 | """ |
| 128 | ) |
| 129 | reprec = pytester.inline_run(p) |
| 130 | passed, skipped, failed = reprec.listoutcomes() |
| 131 | assert (len(passed), len(skipped), len(failed)) == (1, 0, 1) |
| 132 | out = failed[0].longrepr.reprcrash.message # type: ignore[union-attr] |
| 133 | assert out.find("<[reprexc() raised in repr()] BrokenRepr1") != -1 |
| 134 | |
| 135 | def test_broken_repr_with_showlocals_verbose(self, pytester: Pytester) -> None: |
| 136 | p = pytester.makepyfile( |
nothing calls this directly
no test coverage detected