(self)
| 1927 | verified: bool = False |
| 1928 | |
| 1929 | def test_struct_array_like(self): |
| 1930 | msg = self.Account("alice", "munro", 91, True) |
| 1931 | res = roundtrip(msg, self.Account) |
| 1932 | assert res == msg |
| 1933 | |
| 1934 | with pytest.raises(ValidationError, match="Expected `array`, got `int`"): |
| 1935 | roundtrip(1, self.Account) |
| 1936 | |
| 1937 | # Wrong field type |
| 1938 | with pytest.raises( |
| 1939 | ValidationError, match=r"Expected `int`, got `str` - at `\$\[2\]`" |
| 1940 | ): |
| 1941 | roundtrip(("alice", "munro", "bad"), self.Account) |
| 1942 | |
| 1943 | # Missing fields |
| 1944 | with pytest.raises( |
| 1945 | ValidationError, |
| 1946 | match="Expected `array` of at least length 3, got 2", |
| 1947 | ): |
| 1948 | roundtrip(("alice", "munro"), self.Account) |
| 1949 | |
| 1950 | with pytest.raises( |
| 1951 | ValidationError, |
| 1952 | match="Expected `array` of at least length 3, got 0", |
| 1953 | ): |
| 1954 | roundtrip((), self.Account) |
| 1955 | |
| 1956 | @pytest.mark.parametrize("forbid_unknown_fields", [False, True]) |
| 1957 | def test_struct_extra_fields(self, forbid_unknown_fields): |
nothing calls this directly
no test coverage detected