Skip to content

Commit

Permalink
test, gitpython-developers#525: allow disabling freeze errors separately
Browse files Browse the repository at this point in the history
+ cmd: use DEVNULL for non PIPEs; no open-file.
+ TCs: some unitestize-assertions on base & remote TCs.
  • Loading branch information
ankostis committed Oct 12, 2016
1 parent c485e66 commit e6853d5
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 69 deletions.
7 changes: 5 additions & 2 deletions git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ def execute(self, command,
cmd_not_found_exception = OSError
# end handle

stdout_sink = (PIPE
if with_stdout
else getattr(subprocess, 'DEVNULL', open(os.devnull, 'wb')))
log.debug("Popen(%s, cwd=%s, universal_newlines=%s, shell=%s)",
command, cwd, universal_newlines, shell)
try:
Expand All @@ -543,9 +546,9 @@ def execute(self, command,
bufsize=-1,
stdin=istream,
stderr=PIPE,
stdout=PIPE if with_stdout else open(os.devnull, 'wb'),
stdout=stdout_sink,
shell=shell is not None and shell or self.USE_SHELL,
close_fds=(is_posix), # unsupported on windows
close_fds=is_posix, # unsupported on windows
universal_newlines=universal_newlines,
creationflags=PROC_CREATIONFLAGS,
**subprocess_kwargs
Expand Down
27 changes: 13 additions & 14 deletions git/test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from git.objects.util import get_object_type_by_name
from gitdb.util import hex_to_bin
from git.compat import is_win
from git.util import HIDE_WINDOWS_KNOWN_ERRORS


class TestBase(TestBase):
Expand All @@ -42,7 +41,7 @@ def tearDown(self):
def test_base_object(self):
# test interface of base object classes
types = (Blob, Tree, Commit, TagObject)
assert len(types) == len(self.type_tuples)
self.assertEqual(len(types), len(self.type_tuples))

s = set()
num_objs = 0
Expand All @@ -56,12 +55,12 @@ def test_base_object(self):
item = obj_type(self.rorepo, binsha, 0, path)
# END handle index objects
num_objs += 1
assert item.hexsha == hexsha
assert item.type == typename
self.assertEqual(item.hexsha, hexsha)
self.assertEqual(item.type, typename)
assert item.size
assert item == item
assert not item != item
assert str(item) == item.hexsha
self.assertEqual(item, item)
self.assertNotEqual(not item, item)
self.assertEqual(str(item), item.hexsha)
assert repr(item)
s.add(item)

Expand All @@ -79,16 +78,16 @@ def test_base_object(self):

tmpfilename = tempfile.mktemp(suffix='test-stream')
with open(tmpfilename, 'wb+') as tmpfile:
assert item == item.stream_data(tmpfile)
self.assertEqual(item, item.stream_data(tmpfile))
tmpfile.seek(0)
assert tmpfile.read() == data
self.assertEqual(tmpfile.read(), data)
os.remove(tmpfilename)
# END for each object type to create

# each has a unique sha
assert len(s) == num_objs
assert len(s | s) == num_objs
assert num_index_objs == 2
self.assertEqual(len(s), num_objs)
self.assertEqual(len(s | s), num_objs)
self.assertEqual(num_index_objs, 2)

def test_get_object_type_by_name(self):
for tname in base.Object.TYPES:
Expand All @@ -99,7 +98,7 @@ def test_get_object_type_by_name(self):

def test_object_resolution(self):
# objects must be resolved to shas so they compare equal
assert self.rorepo.head.reference.object == self.rorepo.active_branch.object
self.assertEqual(self.rorepo.head.reference.object, self.rorepo.active_branch.object)

@with_rw_repo('HEAD', bare=True)
def test_with_bare_rw_repo(self, bare_rw_repo):
Expand All @@ -111,7 +110,7 @@ def test_with_rw_repo(self, rw_repo):
assert not rw_repo.config_reader("repository").getboolean("core", "bare")
assert os.path.isdir(os.path.join(rw_repo.working_tree_dir, 'lib'))

@skipIf(HIDE_WINDOWS_KNOWN_ERRORS, "FIXME: Freezes!")
#@skipIf(HIDE_WINDOWS_FREEZE_ERRORS, "FIXME: Freezes! sometimes...")
def test_with_rw_remote_and_rw_repo(self):
with rw_and_rw_remote_repos(self.rorepo, '0.1.6') as (rw_repo, rw_remote_repo):
assert not rw_repo.config_reader("repository").getboolean("core", "bare")
Expand Down
Loading

0 comments on commit e6853d5

Please sign in to comment.