Skip to content

Commit 7c2c01f

Browse files
ZackerySpytzvstinner
authored andcommitted
[2.7] bpo-14546: Fix the argument handling in Tools/scripts/lll.py (GH-13026) (GH-13063)
(cherry picked from commit c4e78b1)
1 parent 74852b9 commit 7c2c01f

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

Lib/test/test_tools.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,33 @@ def run_script(self, input="", args=("-",), substfile="xx yy\n"):
445445
return output.getvalue()
446446

447447

448+
class LllTests(unittest.TestCase):
449+
450+
script = os.path.join(scriptsdir, 'lll.py')
451+
452+
@unittest.skipUnless(hasattr(os, 'symlink'), 'Requires symlink support')
453+
def test_lll_multiple_dirs(self):
454+
dir1 = tempfile.mkdtemp()
455+
dir2 = tempfile.mkdtemp()
456+
self.addCleanup(test_support.rmtree, dir1)
457+
self.addCleanup(test_support.rmtree, dir2)
458+
fn1 = os.path.join(dir1, 'foo1')
459+
fn2 = os.path.join(dir2, 'foo2')
460+
for fn, dir in (fn1, dir1), (fn2, dir2):
461+
open(fn, 'w').close()
462+
os.symlink(fn, os.path.join(dir, 'symlink'))
463+
464+
rc, out, err = assert_python_ok(self.script, dir1, dir2)
465+
self.assertEqual(out,
466+
'{dir1}:\n'
467+
'symlink -> {fn1}\n'
468+
'\n'
469+
'{dir2}:\n'
470+
'symlink -> {fn2}\n'
471+
.format(dir1=dir1, fn1=fn1, dir2=dir2, fn2=fn2)
472+
)
473+
474+
448475
def test_main():
449476
test_support.run_unittest(*[obj for obj in globals().values()
450477
if isinstance(obj, type)])
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix the argument handling in Tools/scripts/lll.py.

Tools/scripts/lll.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@ def lll(dirname):
1313
full = os.path.join(dirname, name)
1414
if os.path.islink(full):
1515
print name, '->', os.readlink(full)
16-
def main():
17-
args = sys.argv[1:]
16+
def main(args):
1817
if not args: args = [os.curdir]
1918
first = 1
2019
for arg in args:
2120
if len(args) > 1:
2221
if not first: print
2322
first = 0
2423
print arg + ':'
25-
lll(arg)
24+
lll(arg)
2625

2726
if __name__ == '__main__':
28-
main()
27+
main(sys.argv[1:])

0 commit comments

Comments
 (0)