python (3.11.7)

(root)/
lib/
python3.11/
test/
test_tools/
test_lll.py
       1  """Tests for the lll script in the Tools/script directory."""
       2  
       3  import os
       4  import tempfile
       5  from test import support
       6  from test.support import os_helper
       7  from test.test_tools import skip_if_missing, import_tool
       8  import unittest
       9  
      10  skip_if_missing()
      11  
      12  
      13  class ESC[4;38;5;81mlllTests(ESC[4;38;5;149munittestESC[4;38;5;149m.ESC[4;38;5;149mTestCase):
      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, 'wb').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  
      40  if __name__ == '__main__':
      41      unittest.main()