tempfile: Use random.choises() instead of choise() (GH-23068)
This commit is contained in:
parent
2165cea548
commit
d2810054c7
|
@ -143,10 +143,7 @@ class _RandomNameSequence:
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __next__(self):
|
def __next__(self):
|
||||||
c = self.characters
|
return ''.join(self.rng.choices(self.characters, k=8))
|
||||||
choose = self.rng.choice
|
|
||||||
letters = [choose(c) for dummy in range(8)]
|
|
||||||
return ''.join(letters)
|
|
||||||
|
|
||||||
def _candidate_tempdir_list():
|
def _candidate_tempdir_list():
|
||||||
"""Generate a list of candidate temporary directories which
|
"""Generate a list of candidate temporary directories which
|
||||||
|
|
|
@ -153,8 +153,8 @@ class TestRandomNameSequence(BaseTestCase):
|
||||||
self.r = tempfile._RandomNameSequence()
|
self.r = tempfile._RandomNameSequence()
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
def test_get_six_char_str(self):
|
def test_get_eight_char_str(self):
|
||||||
# _RandomNameSequence returns a six-character string
|
# _RandomNameSequence returns a eight-character string
|
||||||
s = next(self.r)
|
s = next(self.r)
|
||||||
self.nameCheck(s, '', '', '')
|
self.nameCheck(s, '', '', '')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue