|
| 1 | +#-*-coding:utf-8-*- |
1 | 2 | # test_repo.py
|
2 | 3 | # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
|
3 | 4 | #
|
@@ -324,31 +325,32 @@ def test_blame_complex_revision(self, git):
|
324 | 325 | assert len(res) == 1
|
325 | 326 | assert len(res[0][1]) == 83, "Unexpected amount of parsed blame lines"
|
326 | 327 |
|
327 |
| - def test_untracked_files(self): |
328 |
| - base = self.rorepo.working_tree_dir |
329 |
| - files = (join_path_native(base, "__test_myfile"), |
330 |
| - join_path_native(base, "__test_other_file")) |
331 |
| - num_recently_untracked = 0 |
332 |
| - try: |
| 328 | + @with_rw_repo('HEAD', bare=False) |
| 329 | + def test_untracked_files(self, rwrepo): |
| 330 | + for (run, repo_add) in enumerate((rwrepo.index.add, rwrepo.git.add)): |
| 331 | + base = rwrepo.working_tree_dir |
| 332 | + files = (join_path_native(base, u"%i_test _myfile" % run), |
| 333 | + join_path_native(base, "%i_test_other_file" % run), |
| 334 | + join_path_native(base, u"%i__çava verböten" % run), |
| 335 | + join_path_native(base, u"%i_çava-----verböten" % run)) |
| 336 | + |
| 337 | + num_recently_untracked = 0 |
333 | 338 | for fpath in files:
|
334 | 339 | fd = open(fpath, "wb")
|
335 | 340 | fd.close()
|
336 | 341 | # END for each filename
|
337 |
| - untracked_files = self.rorepo.untracked_files |
| 342 | + untracked_files = rwrepo.untracked_files |
338 | 343 | num_recently_untracked = len(untracked_files)
|
339 | 344 |
|
340 | 345 | # assure we have all names - they are relative to the git-dir
|
341 | 346 | num_test_untracked = 0
|
342 | 347 | for utfile in untracked_files:
|
343 | 348 | num_test_untracked += join_path_native(base, utfile) in files
|
344 | 349 | assert len(files) == num_test_untracked
|
345 |
| - finally: |
346 |
| - for fpath in files: |
347 |
| - if os.path.isfile(fpath): |
348 |
| - os.remove(fpath) |
349 |
| - # END handle files |
350 | 350 |
|
351 |
| - assert len(self.rorepo.untracked_files) == (num_recently_untracked - len(files)) |
| 351 | + repo_add(untracked_files) |
| 352 | + assert len(rwrepo.untracked_files) == (num_recently_untracked - len(files)) |
| 353 | + # end for each run |
352 | 354 |
|
353 | 355 | def test_config_reader(self):
|
354 | 356 | reader = self.rorepo.config_reader() # all config files
|
|
0 commit comments