()
| 82 | |
| 83 | |
| 84 | def test_incorrect_encoding() -> None: |
| 85 | gbk_bytes = 'Café'.encode('GBK') |
| 86 | |
| 87 | # deliberately specifying a mismatching encoding (mojibake) |
| 88 | signature = pygit2.Signature(gbk_bytes, 'foo@example.com', 999, 0, encoding='utf-8') |
| 89 | |
| 90 | # repr() and str() may display junk, but they must not crash |
| 91 | assert re.match( |
| 92 | r"pygit2.Signature\('Caf.+', 'foo@example.com', 999, 0, 'utf-8'\)", |
| 93 | repr(signature), |
| 94 | ) |
| 95 | assert re.match(r'Caf.+ <foo@example.com>', str(signature)) |
| 96 | |
| 97 | # deliberately specifying an unsupported encoding |
| 98 | signature = pygit2.Signature( |
| 99 | gbk_bytes, 'foo@example.com', 999, 0, encoding='this-encoding-does-not-exist' |
| 100 | ) |
| 101 | |
| 102 | # repr() and str() may display junk, but they must not crash |
| 103 | assert "pygit2.Signature('(error)', '(error)', 999, 0, '(error)')" == repr( |
| 104 | signature |
| 105 | ) |
| 106 | assert '(error) <(error)>' == str(signature) |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…