Skip to content

Commit d2ff582

Browse files
committed
Index tests adopted to windows - especially the symlink test needed adjustment, but it works as expected even on systems that do not support symlinks
1 parent e0f2bb4 commit d2ff582

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

test/git/test_index.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ def mixed_iterator():
332332

333333
# add fake symlink and assure it checks-our as symlink
334334
fake_symlink_relapath = "my_fake_symlink"
335-
fake_symlink_path = self._make_file(fake_symlink_relapath, "/etc/that", rw_repo)
335+
link_target = "/etc/that"
336+
fake_symlink_path = self._make_file(fake_symlink_relapath, link_target, rw_repo)
336337
fake_entry = BaseIndexEntry((0120000, null_sha, 0, fake_symlink_relapath))
337338
entries = index.reset(new_commit).add([fake_entry])
338339
assert len(entries) == 1 and S_ISLNK(entries[0].mode)
@@ -341,5 +342,12 @@ def mixed_iterator():
341342
assert not S_ISLNK(os.stat(fake_symlink_path)[ST_MODE])
342343
os.remove(fake_symlink_path)
343344
index.checkout(fake_symlink_path)
344-
assert S_ISLNK(os.lstat(fake_symlink_path)[ST_MODE])
345+
346+
# on windows we will never get symlinks
347+
if os.name == 'nt':
348+
# simlinks should contain the link as text ( which is what a
349+
# symlink actually is )
350+
open(fake_symlink_path,'rb').read() == link_target
351+
else:
352+
assert S_ISLNK(os.lstat(fake_symlink_path)[ST_MODE])
345353

test/testlib/helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def fixture_path(name):
1717
return os.path.join(test_dir, "fixtures", name)
1818

1919
def fixture(name):
20-
return open(fixture_path(name)).read()
20+
return open(fixture_path(name), 'rb').read()
2121

2222
def absolute_project_path():
2323
return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))

0 commit comments

Comments
 (0)