From e0f2bb42b56f770c50a6ef087e9049fa6ac11fb5 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 5 Nov 2009 23:15:01 +0100 Subject: ARGH: wb and rb is not the same as r and w on windows, hence reading of binary files went crazy as well as binary writing --- test/git/test_index.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/git/test_index.py') diff --git a/test/git/test_index.py b/test/git/test_index.py index e9541232..6f57538f 100644 --- a/test/git/test_index.py +++ b/test/git/test_index.py @@ -42,7 +42,7 @@ class TestTree(TestBase): # write the data - it must match the original tmpfile = tempfile.mktemp() index_merge.write(tmpfile) - fp = open(tmpfile, 'r') + fp = open(tmpfile, 'rb') assert fp.read() == fixture("index_merge") fp.close() os.remove(tmpfile) @@ -164,14 +164,14 @@ class TestTree(TestBase): # reset the working copy as well to current head,to pull 'back' as well new_data = "will be reverted" file_path = os.path.join(rw_repo.git.git_dir, "CHANGES") - fp = open(file_path, "w") + fp = open(file_path, "wb") fp.write(new_data) fp.close() index.reset(rev_head_parent, working_tree=True) assert not index.diff(None) assert cur_branch == rw_repo.active_branch assert cur_commit == rw_repo.head.commit - fp = open(file_path) + fp = open(file_path,'rb') try: assert fp.read() != new_data finally: -- cgit v1.2.1 From d2ff5822dbefa1c9c8177cbf9f0879c5cf4efc5c Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 6 Nov 2009 10:34:32 +0100 Subject: Index tests adopted to windows - especially the symlink test needed adjustment, but it works as expected even on systems that do not support symlinks --- test/git/test_index.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'test/git/test_index.py') diff --git a/test/git/test_index.py b/test/git/test_index.py index 6f57538f..1a543f82 100644 --- a/test/git/test_index.py +++ b/test/git/test_index.py @@ -332,7 +332,8 @@ class TestTree(TestBase): # add fake symlink and assure it checks-our as symlink fake_symlink_relapath = "my_fake_symlink" - fake_symlink_path = self._make_file(fake_symlink_relapath, "/etc/that", rw_repo) + link_target = "/etc/that" + fake_symlink_path = self._make_file(fake_symlink_relapath, link_target, rw_repo) fake_entry = BaseIndexEntry((0120000, null_sha, 0, fake_symlink_relapath)) entries = index.reset(new_commit).add([fake_entry]) assert len(entries) == 1 and S_ISLNK(entries[0].mode) @@ -341,5 +342,12 @@ class TestTree(TestBase): assert not S_ISLNK(os.stat(fake_symlink_path)[ST_MODE]) os.remove(fake_symlink_path) index.checkout(fake_symlink_path) - assert S_ISLNK(os.lstat(fake_symlink_path)[ST_MODE]) + + # on windows we will never get symlinks + if os.name == 'nt': + # simlinks should contain the link as text ( which is what a + # symlink actually is ) + open(fake_symlink_path,'rb').read() == link_target + else: + assert S_ISLNK(os.lstat(fake_symlink_path)[ST_MODE]) -- cgit v1.2.1