Skip to content

Commit 53d94bb

Browse 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

File tree

4 files changed

+77
-69
lines changed

4 files changed

+77
-69
lines changed

‎git/cmd.py‎

Lines 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+
ifwith_stdout
544+
elsegetattr(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=PIPEifwith_stdoutelseopen(os.devnull, 'wb'),
554+
stdout=stdout_sink,
552555
shell=shellisnotNoneandshellorself.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‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
fromgit.objects.utilimportget_object_type_by_name
2626
fromgitdb.utilimporthex_to_bin
2727
fromgit.compatimportis_win
28-
fromgit.utilimportHIDE_WINDOWS_KNOWN_ERRORS
2928

3029

3130
classTestBase(TestBase):
@@ -42,7 +41,7 @@ def tearDown(self):
4241
deftest_base_object(self):
4342
# test interface of base object classes
4443
types= (Blob, Tree, Commit, TagObject)
45-
assertlen(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-
assertitem.hexsha==hexsha
60-
assertitem.type==typename
58+
self.assertEqual(item.hexsha, hexsha)
59+
self.assertEqual(item.type, typename)
6160
assertitem.size
62-
assertitem==item
63-
assertnotitem!=item
64-
assertstr(item)==item.hexsha
61+
self.assertEqual(item, item)
62+
self.assertNotEqual(notitem, item)
63+
self.assertEqual(str(item), item.hexsha)
6564
assertrepr(item)
6665
s.add(item)
6766

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

8079
tmpfilename=tempfile.mktemp(suffix='test-stream')
8180
withopen(tmpfilename, 'wb+') astmpfile:
82-
assertitem==item.stream_data(tmpfile)
81+
self.assertEqual(item, item.stream_data(tmpfile))
8382
tmpfile.seek(0)
84-
asserttmpfile.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-
assertlen(s)==num_objs
90-
assertlen(s|s)==num_objs
91-
assertnum_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
deftest_get_object_type_by_name(self):
9493
fortnameinbase.Object.TYPES:
@@ -99,7 +98,7 @@ def test_get_object_type_by_name(self):
9998

10099
deftest_object_resolution(self):
101100
# objects must be resolved to shas so they compare equal
102-
assertself.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
deftest_with_bare_rw_repo(self, bare_rw_repo):
@@ -111,7 +110,7 @@ def test_with_rw_repo(self, rw_repo):
111110
assertnotrw_repo.config_reader("repository").getboolean("core", "bare")
112111
assertos.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
deftest_with_rw_remote_and_rw_repo(self):
116115
withrw_and_rw_remote_repos(self.rorepo, '0.1.6') as (rw_repo, rw_remote_repo):
117116
assertnotrw_repo.config_reader("repository").getboolean("core", "bare")

0 commit comments

Comments
(0)