summaryrefslogtreecommitdiff
path: root/git/test/test_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/test/test_base.py')
-rw-r--r--git/test/test_base.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/git/test/test_base.py b/git/test/test_base.py
index 7b71a77e..e5e8f173 100644
--- a/git/test/test_base.py
+++ b/git/test/test_base.py
@@ -7,6 +7,7 @@
import os
import sys
import tempfile
+from unittest import skipIf
import git.objects.base as base
from git.test.lib import (
@@ -23,10 +24,15 @@ from git import (
)
from git.objects.util import get_object_type_by_name
from gitdb.util import hex_to_bin
+from git.compat import is_win
class TestBase(TestBase):
+ def tearDown(self):
+ import gc
+ gc.collect()
+
type_tuples = (("blob", "8741fc1d09d61f02ffd8cded15ff603eff1ec070", "blob.py"),
("tree", "3a6a5e3eeed3723c09f1ef0399f81ed6b8d82e79", "directory"),
("commit", "4251bd59fb8e11e40c40548cba38180a9536118c", None),
@@ -71,13 +77,11 @@ class TestBase(TestBase):
assert data
tmpfilename = tempfile.mktemp(suffix='test-stream')
- tmpfile = open(tmpfilename, 'wb+')
- assert item == item.stream_data(tmpfile)
- tmpfile.seek(0)
- assert tmpfile.read() == data
- tmpfile.close()
+ with open(tmpfilename, 'wb+') as tmpfile:
+ assert item == item.stream_data(tmpfile)
+ tmpfile.seek(0)
+ assert tmpfile.read() == data
os.remove(tmpfilename)
- # END stream to file directly
# END for each object type to create
# each has a unique sha
@@ -112,6 +116,8 @@ class TestBase(TestBase):
assert rw_remote_repo.config_reader("repository").getboolean("core", "bare")
assert os.path.isdir(os.path.join(rw_repo.working_tree_dir, 'lib'))
+ @skipIf(sys.version_info < (3,) and is_win,
+ "Unicode woes, see https://github.com/gitpython-developers/GitPython/pull/519")
@with_rw_repo('0.1.6')
def test_add_unicode(self, rw_repo):
filename = u"שלום.txt"
@@ -125,9 +131,10 @@ class TestBase(TestBase):
from nose import SkipTest
raise SkipTest("Environment doesn't support unicode filenames")
- open(file_path, "wb").write(b'something')
+ with open(file_path, "wb") as fp:
+ fp.write(b'something')
- if os.name == 'nt':
+ if is_win:
# on windows, there is no way this works, see images on
# https://github.com/gitpython-developers/GitPython/issues/147#issuecomment-68881897
# Therefore, it must be added using the python implementation