gh-96189: Fix test_invalid_utf8 on a number of build bots (GH-96190)

The clearing of the temporary directory is not working on some platforms and
leaving behind files.

This has been updated to use the pattern in test_cmd_line.py [1] using the
special TESTFN rather than a test directory.

[1] https://github.com/python/cpython/blob/main/Lib/test/test_cmd_line.py#L559
This commit is contained in:
Michael Droettboom 2022-08-23 16:52:55 -04:00 committed by GitHub
parent e046cf872e
commit 054328f0dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 38 deletions

View File

@ -239,8 +239,8 @@ def test_invalid_utf8(self):
# it's an otherwise valid Python source file.
template = b'"%s"\n'
with tempfile.TemporaryDirectory() as tmpd:
fn = os.path.join(tmpd, 'test.py')
fn = TESTFN
self.addCleanup(unlink, fn)
def check(content):
with open(fn, 'wb') as fp: