Skip to content

Commit 56ec4f1

Browse files
aerosmiss-islington
authored andcommitted
bpo-19696: Replace deprecated method in "test_import_pkg.py" (GH-14466)
Replacing the deprecated method "random.choose" to "random.choice" was technically not part of the original issue. However, it was discussed in the talk page and involved one of the files being moved. I assumed this was too minor to justify the creation of a separate issue. Also, I added my name to the contributors list in Misc/ACKS. This will be my third PR to cpython, forgot to do it in the previous ones. https://bugs.python.org/issue19696
1 parent 53c2143 commit 56ec4f1

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

Lib/test/test_importlib/test_pkg_import.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class TestImport(unittest.TestCase):
1414
def __init__(self, *args, **kw):
1515
self.package_name = 'PACKAGE_'
1616
while self.package_name in sys.modules:
17-
self.package_name += random.choose(string.ascii_letters)
17+
self.package_name += random.choice(string.ascii_letters)
1818
self.module_name = self.package_name + '.foo'
1919
unittest.TestCase.__init__(self, *args, **kw)
2020

@@ -60,7 +60,7 @@ def test_package_import__semantics(self):
6060
# ...make up a variable name that isn't bound in __builtins__
6161
var = 'a'
6262
while var in dir(__builtins__):
63-
var += random.choose(string.ascii_letters)
63+
var += random.choice(string.ascii_letters)
6464

6565
# ...make a module that just contains that
6666
self.rewrite_file(var)

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,7 @@ Tage Stabell-Kulo
15721572
Quentin Stafford-Fraser
15731573
Frank Stajano
15741574
Joel Stanley
1575+
Kyle Stanley
15751576
Anthony Starks
15761577
David Steele
15771578
Oliver Steele
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replace deprecated method "random.choose" with "random.choice" in "test_pkg_import.py".

0 commit comments

Comments
 (0)