()
| 5 | |
| 6 | |
| 7 | def test_expect(): |
| 8 | class Foo: |
| 9 | @expect(str, int) |
| 10 | def foo(self, x): |
| 11 | return "".join(reversed(x)) |
| 12 | |
| 13 | @expect(str) |
| 14 | def bar(self, x): |
| 15 | yield "".join(reversed(x)) |
| 16 | |
| 17 | f = Foo() |
| 18 | |
| 19 | assert f.foo("foo") == "oof" |
| 20 | assert list(f.bar("bar")) == ["rab"] |
| 21 | with pytest.raises(AssertionError, match=r"Expected str\|int, got None."): |
| 22 | f.foo(None) |
| 23 | |
| 24 | |
| 25 | def test_receive_buffer(): |