tempfile: Use random.choises() instead of choise() (GH-23068)

This commit is contained in:
Inada Naoki 2020-11-01 20:02:03 +09:00 committed by GitHub
parent 2165cea548
commit d2810054c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View File

@ -143,10 +143,7 @@ class _RandomNameSequence:
return self
def __next__(self):
c = self.characters
choose = self.rng.choice
letters = [choose(c) for dummy in range(8)]
return ''.join(letters)
return ''.join(self.rng.choices(self.characters, k=8))
def _candidate_tempdir_list():
"""Generate a list of candidate temporary directories which

View File

@ -153,8 +153,8 @@ class TestRandomNameSequence(BaseTestCase):
self.r = tempfile._RandomNameSequence()
super().setUp()
def test_get_six_char_str(self):
# _RandomNameSequence returns a six-character string
def test_get_eight_char_str(self):
# _RandomNameSequence returns a eight-character string
s = next(self.r)
self.nameCheck(s, '', '', '')