MCPcopy Create free account
hub / github.com/libgit2/pygit2 / test_incorrect_encoding

Function test_incorrect_encoding

test/test_signature.py:84–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

82
83
84def 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)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…