def test_untracked_files(self, rwrepo): for run, (repo_add, is_invoking_git) in enumerate(( (rwrepo.index.add, False), (rwrepo.git.add, True), )): base = rwrepo.working_tree_dir files = (join_path_native(base, u"%i_test _myfile" % run), join_path_native(base, "%i_test_other_file" % run), join_path_native(base, u"%i__çava verböten" % run), join_path_native(base, u"%i_çava-----verböten" % run)) num_recently_untracked = 0 for fpath in files: with open(fpath, "wb"): pass untracked_files = rwrepo.untracked_files num_recently_untracked = len(untracked_files) # assure we have all names - they are relative to the git-dir num_test_untracked = 0 for utfile in untracked_files: num_test_untracked += join_path_native(base, utfile) in files self.assertEqual(len(files), num_test_untracked) if is_win and not PY3 and is_invoking_git: ## On Windows, shell needed when passing unicode cmd-args. # repo_add = fnt.partial(repo_add, shell=True) untracked_files = [win_encode(f) for f in untracked_files] repo_add(untracked_files) self.assertEqual(len(rwrepo.untracked_files), (num_recently_untracked - len(files)))