Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 53d94bb

Browse filesBrowse files
committed
test, #525: allow disabling freeze errors separately
+ cmd: use DEVNULL for non PIPEs; no open-file. + TCs: some unitestize-assertions on base & remote TCs.
1 parent b202ec7 commit 53d94bb
Copy full SHA for 53d94bb

File tree

4 files changed

+77
-69
lines changed
Filter options

4 files changed

+77
-69
lines changed

‎git/cmd.py

Copy file name to clipboardExpand all lines: git/cmd.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,9 @@ def execute(self, command,
539539
cmd_not_found_exception = OSError
540540
# end handle
541541

542+
stdout_sink = (PIPE
543+
if with_stdout
544+
else getattr(subprocess, 'DEVNULL', open(os.devnull, 'wb')))
542545
log.debug("Popen(%s, cwd=%s, universal_newlines=%s, shell=%s)",
543546
command, cwd, universal_newlines, shell)
544547
try:
@@ -548,9 +551,9 @@ def execute(self, command,
548551
bufsize=-1,
549552
stdin=istream,
550553
stderr=PIPE,
551-
stdout=PIPE if with_stdout else open(os.devnull, 'wb'),
554+
stdout=stdout_sink,
552555
shell=shell is not None and shell or self.USE_SHELL,
553-
close_fds=(is_posix), # unsupported on windows
556+
close_fds=is_posix, # unsupported on windows
554557
universal_newlines=universal_newlines,
555558
creationflags=PROC_CREATIONFLAGS,
556559
**subprocess_kwargs

‎git/test/test_base.py

Copy file name to clipboardExpand all lines: git/test/test_base.py
+13-14Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from git.objects.util import get_object_type_by_name
2626
from gitdb.util import hex_to_bin
2727
from git.compat import is_win
28-
from git.util import HIDE_WINDOWS_KNOWN_ERRORS
2928

3029

3130
class TestBase(TestBase):
@@ -42,7 +41,7 @@ def tearDown(self):
4241
def test_base_object(self):
4342
# test interface of base object classes
4443
types = (Blob, Tree, Commit, TagObject)
45-
assert len(types) == len(self.type_tuples)
44+
self.assertEqual(len(types), len(self.type_tuples))
4645

4746
s = set()
4847
num_objs = 0
@@ -56,12 +55,12 @@ def test_base_object(self):
5655
item = obj_type(self.rorepo, binsha, 0, path)
5756
# END handle index objects
5857
num_objs += 1
59-
assert item.hexsha == hexsha
60-
assert item.type == typename
58+
self.assertEqual(item.hexsha, hexsha)
59+
self.assertEqual(item.type, typename)
6160
assert item.size
62-
assert item == item
63-
assert not item != item
64-
assert str(item) == item.hexsha
61+
self.assertEqual(item, item)
62+
self.assertNotEqual(not item, item)
63+
self.assertEqual(str(item), item.hexsha)
6564
assert repr(item)
6665
s.add(item)
6766

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

8079
tmpfilename = tempfile.mktemp(suffix='test-stream')
8180
with open(tmpfilename, 'wb+') as tmpfile:
82-
assert item == item.stream_data(tmpfile)
81+
self.assertEqual(item, item.stream_data(tmpfile))
8382
tmpfile.seek(0)
84-
assert tmpfile.read() == data
83+
self.assertEqual(tmpfile.read(), data)
8584
os.remove(tmpfilename)
8685
# END for each object type to create
8786

8887
# each has a unique sha
89-
assert len(s) == num_objs
90-
assert len(s | s) == num_objs
91-
assert num_index_objs == 2
88+
self.assertEqual(len(s), num_objs)
89+
self.assertEqual(len(s | s), num_objs)
90+
self.assertEqual(num_index_objs, 2)
9291

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

10099
def test_object_resolution(self):
101100
# objects must be resolved to shas so they compare equal
102-
assert self.rorepo.head.reference.object == self.rorepo.active_branch.object
101+
self.assertEqual(self.rorepo.head.reference.object, self.rorepo.active_branch.object)
103102

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

114-
@skipIf(HIDE_WINDOWS_KNOWN_ERRORS, "FIXME: Freezes!")
113+
#@skipIf(HIDE_WINDOWS_FREEZE_ERRORS, "FIXME: Freezes! sometimes...")
115114
def test_with_rw_remote_and_rw_repo(self):
116115
with rw_and_rw_remote_repos(self.rorepo, '0.1.6') as (rw_repo, rw_remote_repo):
117116
assert not rw_repo.config_reader("repository").getboolean("core", "bare")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.