()
| 6 | |
| 7 | |
| 8 | def test_hook(): |
| 9 | with pytest.raises(TypeError, match="may not be instantiated directly"): |
| 10 | hooks.Hook() |
| 11 | |
| 12 | class NoDataClass(hooks.Hook): |
| 13 | pass |
| 14 | |
| 15 | with pytest.raises(TypeError, match="not a dataclass"): |
| 16 | NoDataClass() |
| 17 | |
| 18 | @dataclass |
| 19 | class FooHook(hooks.Hook): |
| 20 | data: bytes |
| 21 | |
| 22 | e = FooHook(b"foo") |
| 23 | assert repr(e) |
| 24 | assert e.args() == [b"foo"] |
| 25 | assert FooHook in hooks.all_hooks.values() |
| 26 | |
| 27 | with pytest.warns(RuntimeWarning, match="Two conflicting event classes"): |
| 28 | |
| 29 | @dataclass |
| 30 | class FooHook2(hooks.Hook): |
| 31 | name = "foo" |
| 32 | |
| 33 | @dataclass |
| 34 | class AnotherABC(hooks.Hook): |
| 35 | name = "" |
| 36 | |
| 37 | assert AnotherABC not in hooks.all_hooks.values() |
nothing calls this directly
no test coverage detected
searching dependent graphs…