Skip to content

Commit 7e606dd

Browse files
committed
Revert "bpo-38347: add a test case for the recursive search"
This reverts commit 9c512f4.
1 parent a1be155 commit 7e606dd

File tree

1 file changed

+16
-35
lines changed

1 file changed

+16
-35
lines changed

Lib/test/test_tools/test_pathfix.py

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,16 @@ class TestPathfixFunctional(unittest.TestCase):
1414
script = os.path.join(scriptsdir, 'pathfix.py')
1515

1616
def setUp(self):
17-
self.temp_directory = support.TESTFN + '.d'
18-
self.addCleanup(support.rmtree, self.temp_directory)
19-
os.mkdir(self.temp_directory)
20-
self.temp_file = self.temp_directory + '/' + \
21-
os.path.basename(support.TESTFN) + '-t.py'
22-
self.addCleanup(support.unlink, self.temp_file)
23-
24-
def pathfix(self, shebang, pathfix_flags, exitcode=0, stdout='', stderr='',
25-
target_file=''):
26-
if target_file == '':
27-
target_file = self.temp_file
17+
self.temp_file = support.TESTFN
18+
self.addCleanup(support.unlink, support.TESTFN)
2819

20+
def pathfix(self, shebang, pathfix_flags, exitcode=0, stdout='', stderr=''):
2921
with open(self.temp_file, 'w', encoding='utf8') as f:
3022
f.write(f'{shebang}\n' + 'print("Hello world")\n')
3123

3224
proc = subprocess.run(
3325
[sys.executable, self.script,
34-
*pathfix_flags, '-n', target_file],
26+
*pathfix_flags, '-n', self.temp_file],
3527
capture_output=True, text=1)
3628

3729
if stdout == '' and proc.returncode == 0:
@@ -52,66 +44,55 @@ def pathfix(self, shebang, pathfix_flags, exitcode=0, stdout='', stderr='',
5244

5345
return new_shebang
5446

55-
def test_recursive(self):
56-
temp_directory_basename = os.path.basename(self.temp_directory)
57-
expected_stderr = f'recursedown(\'{temp_directory_basename}\')\n'
58-
for method_name in dir(self):
59-
method = getattr(self, method_name)
60-
if method_name.startswith('test_') and \
61-
method_name != 'test_recursive' and \
62-
method_name != 'test_pathfix_adding_errors' and \
63-
callable(method):
64-
method(target_file=self.temp_directory, stderr=expected_stderr)
65-
66-
def test_pathfix(self, **kwargs):
47+
def test_pathfix(self):
6748
self.assertEqual(
6849
self.pathfix(
6950
'#! /usr/bin/env python',
70-
['-i', '/usr/bin/python3'], **kwargs),
51+
['-i', '/usr/bin/python3']),
7152
'#! /usr/bin/python3')
7253
self.assertEqual(
7354
self.pathfix(
7455
'#! /usr/bin/env python -R',
75-
['-i', '/usr/bin/python3'], **kwargs),
56+
['-i', '/usr/bin/python3']),
7657
'#! /usr/bin/python3')
7758

78-
def test_pathfix_keeping_flags(self, **kwargs):
59+
def test_pathfix_keeping_flags(self):
7960
self.assertEqual(
8061
self.pathfix(
8162
'#! /usr/bin/env python -R',
82-
['-i', '/usr/bin/python3', '-k'], **kwargs),
63+
['-i', '/usr/bin/python3', '-k']),
8364
'#! /usr/bin/python3 -R')
8465
self.assertEqual(
8566
self.pathfix(
8667
'#! /usr/bin/env python',
87-
['-i', '/usr/bin/python3', '-k'], **kwargs),
68+
['-i', '/usr/bin/python3', '-k']),
8869
'#! /usr/bin/python3')
8970

90-
def test_pathfix_adding_flag(self, **kwargs):
71+
def test_pathfix_adding_flag(self):
9172
self.assertEqual(
9273
self.pathfix(
9374
'#! /usr/bin/env python',
94-
['-i', '/usr/bin/python3', '-a', 's'], **kwargs),
75+
['-i', '/usr/bin/python3', '-a', 's']),
9576
'#! /usr/bin/python3 -s')
9677
self.assertEqual(
9778
self.pathfix(
9879
'#! /usr/bin/env python -S',
99-
['-i', '/usr/bin/python3', '-a', 's'], **kwargs),
80+
['-i', '/usr/bin/python3', '-a', 's']),
10081
'#! /usr/bin/python3 -s')
10182
self.assertEqual(
10283
self.pathfix(
10384
'#! /usr/bin/env python -V',
104-
['-i', '/usr/bin/python3', '-a', 'v', '-k'], **kwargs),
85+
['-i', '/usr/bin/python3', '-a', 'v', '-k']),
10586
'#! /usr/bin/python3 -vV')
10687
self.assertEqual(
10788
self.pathfix(
10889
'#! /usr/bin/env python',
109-
['-i', '/usr/bin/python3', '-a', 'Rs'], **kwargs),
90+
['-i', '/usr/bin/python3', '-a', 'Rs']),
11091
'#! /usr/bin/python3 -Rs')
11192
self.assertEqual(
11293
self.pathfix(
11394
'#! /usr/bin/env python -W default',
114-
['-i', '/usr/bin/python3', '-a', 's', '-k'], **kwargs),
95+
['-i', '/usr/bin/python3', '-a', 's', '-k']),
11596
'#! /usr/bin/python3 -sW default')
11697

11798
def test_pathfix_adding_errors(self):

0 commit comments

Comments
 (0)