1"""Tests for the lll script in the Tools/script directory.""" 2 3import os 4import tempfile 5from test import support 6from test.support import os_helper 7from test.test_tools import skip_if_missing, import_tool 8import unittest 9 10skip_if_missing() 11 12 13class lllTests(unittest.TestCase): 14 15 def setUp(self): 16 self.lll = import_tool('lll') 17 18 @os_helper.skip_unless_symlink 19 def test_lll_multiple_dirs(self): 20 with tempfile.TemporaryDirectory() as dir1, \ 21 tempfile.TemporaryDirectory() as dir2: 22 fn1 = os.path.join(dir1, 'foo1') 23 fn2 = os.path.join(dir2, 'foo2') 24 for fn, dir in (fn1, dir1), (fn2, dir2): 25 open(fn, 'w').close() 26 os.symlink(fn, os.path.join(dir, 'symlink')) 27 28 with support.captured_stdout() as output: 29 self.lll.main([dir1, dir2]) 30 prefix = '\\\\?\\' if os.name == 'nt' else '' 31 self.assertEqual(output.getvalue(), 32 f'{dir1}:\n' 33 f'symlink -> {prefix}{fn1}\n' 34 f'\n' 35 f'{dir2}:\n' 36 f'symlink -> {prefix}{fn2}\n' 37 ) 38 39 40if __name__ == '__main__': 41 unittest.main() 42