MCPcopy Index your code
hub / github.com/pex-tool/pex / test_script_encoding_bad

Function test_script_encoding_bad

tests/integration/test_script_metadata.py:267–291  ·  view source on GitHub ↗
(
    tmpdir,  # type: Tempdir
    encoding_comment,  # type: str
    comment_line,  # type: int
    pos,  # type: int
)

Source from the content-addressed store, hash-verified

265)
266@pytest.mark.parametrize("comment_line", [1, 2])
267def test_script_encoding_bad(
268 tmpdir, # type: Tempdir
269 encoding_comment, # type: str
270 comment_line, # type: int
271 pos, # type: int
272):
273 # type: (...) -> None
274
275 script = tmpdir.join("incorrect-encoding-comment.py")
276 with open(script, "w") as fp:
277 if comment_line == 2:
278 shebang = "#!/usr/bin/env python"
279 print(shebang, file=fp)
280 pos += len(shebang) + len(os.linesep)
281 print(encoding_comment, file=fp)
282 print("# micro: µ", file=fp)
283
284 with pytest.raises(
285 UnicodeDecodeError,
286 match=re.escape(
287 "'ascii' codec can't decode byte 0xc2 in position {pos}: "
288 "ordinal not in range(128)".format(pos=pos)
289 ),
290 ):
291 apply_script_metadata([script])
292
293
294def test_script_encoding_default(tmpdir):

Callers

nothing calls this directly

Calls 2

apply_script_metadataFunction · 0.90
joinMethod · 0.45

Tested by

no test coverage detected