Пример #1
0
 def test_at_root_yields_only_once(self, mock_getcwd):
     """We should only get root once. # noqa"""
     mock_getcwd.return_value = '/'
     path_walker = walk_path()
     self.assertEqual(next(path_walker), '/')
     with self.assertRaises(StopIteration):
         next(path_walker)
Пример #2
0
 def test_really_long_path(self, mock_getcwd):
     directories = [
         ''.join(
             [choice(ascii_letters + '_-') for _ in range(randint(1, 10))])
         for __ in range(randint(10, 30))
     ]
     cwd = '/' + '/'.join(directories)
     mock_getcwd.return_value = cwd
     path_walker = walk_path()
     paths_walked = [x for x in path_walker]
     self.assertEqual(
         len(paths_walked),
         len(directories) + 1,
         'Should have had {} but had {} paths.'.format(
             len(directories),
             len(paths_walked) + 1,
         ))