def test_top_down(self, topdown=True, expected=None):
     """Walk the tree top-down."""
     valid_base_dir = get_windows_valid_path(self.basedir)
     result = os.walk(valid_base_dir, topdown)
     expected = self._build_dict_from_walk(
         result, path_transformer=get_syncdaemon_valid_path,
         name_transformer=_unicode_to_bytes)
     super(TestIllegalPathsWalk, self).test_top_down(topdown=topdown,
                                                     expected=expected)
    def setUp(self):
        """Setup for the tests."""
        yield super(TestAccess, self).setUp()

        self.basedir = self.mktemp('test_root')
        self.addCleanup(set_dir_readwrite, self.basedir)

        self.testfile = os.path.join(self.basedir, "test_file")
        self.valid_path = get_windows_valid_path(self.testfile)
        open(self.testfile, 'w').close()
        self.addCleanup(set_file_readwrite, self.testfile)
 def test_normpath_with_longprefix(self):
     """Ensure that the normpath is correct when it uses the long prefix."""
     paths = [os.path.join('A', 'B?'),
              os.path.join('A', 'B?') + os.path.sep,
              os.path.join('A:C', '.', 'B?'),
              os.path.join('A', 'foo', '..', 'B?')]
     for current_path in paths:
         valid_path = get_windows_valid_path(current_path)
         normalized_path = os.path.normpath(valid_path)
         self.assertEqual(get_syncdaemon_valid_path(normalized_path),
                          normpath(current_path))
         self.assertFalse(LONG_PATH_PREFIX in current_path)
 def test_rename_dir(self, source=None, target=None):
     """Rename a dir."""
     source = os.path.join(self.basedir, 'source?!><:')
     os.mkdir(get_windows_valid_path(source))
     target = os.path.join(self.basedir, 'target?!><:')
     super(TestIllegalPaths, self).test_rename_dir(source, target)