From 929f3e1e1b664ed8cdef90a40c96804edfd08d59 Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 18 Mar 2018 12:06:10 +0200 Subject: Drop support for EOL Python 2.6 --- git/test/test_index.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'git/test/test_index.py') diff --git a/git/test/test_index.py b/git/test/test_index.py index 757bec9f..73123d6b 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -11,12 +11,8 @@ from stat import ( S_ISLNK, ST_MODE ) -import sys import tempfile -try: - from unittest import skipIf -except ImportError: - from unittest2 import skipIf +from unittest import skipIf from git import ( IndexFile, @@ -168,9 +164,7 @@ class TestIndex(TestBase): except Exception as ex: msg_py3 = "required argument is not an integer" msg_py2 = "cannot convert argument to integer" - msg_py26 = "unsupported operand type(s) for &: 'str' and 'long'" - assert msg_py2 in str(ex) or msg_py3 in str(ex) or \ - msg_py26 in str(ex), str(ex) + assert msg_py2 in str(ex) or msg_py3 in str(ex) ## 2nd time should not fail due to stray lock file try: @@ -180,9 +174,6 @@ class TestIndex(TestBase): @with_rw_repo('0.1.6') def test_index_file_from_tree(self, rw_repo): - if sys.version_info < (2, 7): - ## Skipped, not `assertRaisesRegexp` in py2.6 - return common_ancestor_sha = "5117c9c8a4d3af19a9958677e45cda9269de1541" cur_sha = "4b43ca7ff72d5f535134241e7c797ddc9c7a3573" other_sha = "39f85c4358b7346fee22169da9cad93901ea9eb9" -- cgit v1.2.1 From 14582df679a011e8c741eb5dcd8126f883e1bc71 Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 18 Mar 2018 20:03:02 +0200 Subject: Replace function call with set literal --- git/test/test_index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/test/test_index.py') diff --git a/git/test/test_index.py b/git/test/test_index.py index 73123d6b..ec3c59df 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -226,7 +226,7 @@ class TestIndex(TestBase): def test_index_merge_tree(self, rw_repo): # A bit out of place, but we need a different repo for this: self.assertNotEqual(self.rorepo, rw_repo) - self.assertEqual(len(set((self.rorepo, self.rorepo, rw_repo, rw_repo))), 2) + self.assertEqual(len({self.rorepo, self.rorepo, rw_repo, rw_repo}), 2) # SINGLE TREE MERGE # current index is at the (virtual) cur_commit -- cgit v1.2.1 From ac4f7d34f8752ab78949efcaa9f0bd938df33622 Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 18 Mar 2018 21:33:18 +0200 Subject: Rewrite unnecessary dict/list/tuple calls as literals --- git/test/test_index.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'git/test/test_index.py') diff --git a/git/test/test_index.py b/git/test/test_index.py index ec3c59df..56c7e795 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -97,7 +97,7 @@ class TestIndex(TestBase): def _reset_progress(self): # maps paths to the count of calls - self._fprogress_map = dict() + self._fprogress_map = {} def _assert_entries(self, entries): for entry in entries: @@ -141,7 +141,7 @@ class TestIndex(TestBase): if isinstance(tree, str): tree = self.rorepo.commit(tree).tree - blist = list() + blist = [] for blob in tree.traverse(predicate=lambda e, d: e.type == "blob", branch_first=False): assert (blob.path, 0) in index.entries blist.append(blob) @@ -527,7 +527,7 @@ class TestIndex(TestBase): # same index, no parents commit_message = "index without parents" - commit_no_parents = index.commit(commit_message, parent_commits=list(), head=True) + commit_no_parents = index.commit(commit_message, parent_commits=[], head=True) self.assertEqual(commit_no_parents.message, commit_message) self.assertEqual(len(commit_no_parents.parents), 0) self.assertEqual(cur_head.commit, commit_no_parents) -- cgit v1.2.1 From 87a644184b05e99a4809de378f21424ef6ced06e Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 18 Mar 2018 21:43:41 +0200 Subject: Unnecessary generator - rewrite as a list comprehension --- git/test/test_index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git/test/test_index.py') diff --git a/git/test/test_index.py b/git/test/test_index.py index 56c7e795..04638c57 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -127,7 +127,7 @@ class TestIndex(TestBase): # test stage index_merge = IndexFile(self.rorepo, fixture_path("index_merge")) self.assertEqual(len(index_merge.entries), 106) - assert len(list(e for e in index_merge.entries.values() if e.stage != 0)) + assert len([e for e in index_merge.entries.values() if e.stage != 0]) # write the data - it must match the original tmpfile = tempfile.mktemp() @@ -190,7 +190,7 @@ class TestIndex(TestBase): # merge three trees - here we have a merge conflict three_way_index = IndexFile.from_tree(rw_repo, common_ancestor_sha, cur_sha, other_sha) - assert len(list(e for e in three_way_index.entries.values() if e.stage != 0)) + assert len([e for e in three_way_index.entries.values() if e.stage != 0]) # ITERATE BLOBS merge_required = lambda t: t[0] != 0 -- cgit v1.2.1 From db0dfa07e34ed80bfe0ce389da946755ada13c5d Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 18 Mar 2018 21:50:16 +0200 Subject: Unnecessary generator - rewrite as a set comprehension --- git/test/test_index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git/test/test_index.py') diff --git a/git/test/test_index.py b/git/test/test_index.py index 04638c57..c7739ce8 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -147,8 +147,8 @@ class TestIndex(TestBase): blist.append(blob) # END for each blob in tree if len(blist) != len(index.entries): - iset = set(k[0] for k in index.entries.keys()) - bset = set(b.path for b in blist) + iset = {k[0] for k in index.entries.keys()} + bset = {b.path for b in blist} raise AssertionError("CMP Failed: Missing entries in index: %s, missing in tree: %s" % (bset - iset, iset - bset)) # END assertion message -- cgit v1.2.1 From 16223e5828ccc8812bd0464d41710c28379c57a9 Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 18 Mar 2018 21:57:00 +0200 Subject: Use automatic formatters --- git/test/test_index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git/test/test_index.py') diff --git a/git/test/test_index.py b/git/test/test_index.py index c7739ce8..9be4031d 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -882,10 +882,10 @@ class TestIndex(TestBase): _make_hook( index.repo.git_dir, 'commit-msg', - 'echo -n " {0}" >> "$1"'.format(from_hook_message) + 'echo -n " {}" >> "$1"'.format(from_hook_message) ) new_commit = index.commit(commit_message) - self.assertEqual(new_commit.message, u"{0} {1}".format(commit_message, from_hook_message)) + self.assertEqual(new_commit.message, u"{} {}".format(commit_message, from_hook_message)) @with_rw_repo('HEAD', bare=True) def test_commit_msg_hook_fail(self, rw_repo): -- cgit v1.2.1