summaryrefslogtreecommitdiff
path: root/git/test
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2018-03-24 13:45:17 +0100
committerGitHub <noreply@github.com>2018-03-24 13:45:17 +0100
commitf3265bd8beb017890699d093586126ff8af4a3fe (patch)
treeccf02df66dbb979c7f6da6949456902a06aa1b1e /git/test
parent9f12b26b81a8e7667b2a26a7878e5bc033610ed5 (diff)
parent80b038f8d8c7c67c148ebd7a5f7a0cb39541b761 (diff)
downloadgitpython-f3265bd8beb017890699d093586126ff8af4a3fe.tar.gz
Merge pull request #737 from hugovk/rm-2.6
Drop support for EOL Python 2.6 and 3.3
Diffstat (limited to 'git/test')
-rw-r--r--git/test/lib/helper.py7
-rw-r--r--git/test/performance/test_odb.py4
-rw-r--r--git/test/performance/test_streams.py2
-rw-r--r--git/test/test_base.py5
-rw-r--r--git/test/test_diff.py2
-rw-r--r--git/test/test_docs.py2
-rw-r--r--git/test/test_fun.py8
-rw-r--r--git/test/test_git.py2
-rw-r--r--git/test/test_index.py33
-rw-r--r--git/test/test_refs.py2
-rw-r--r--git/test/test_remote.py9
-rw-r--r--git/test/test_repo.py13
-rw-r--r--git/test/test_submodule.py7
-rw-r--r--git/test/test_tree.py11
-rw-r--r--git/test/test_util.py5
15 files changed, 35 insertions, 77 deletions
diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py
index cb46173d..1c06010f 100644
--- a/git/test/lib/helper.py
+++ b/git/test/lib/helper.py
@@ -15,6 +15,7 @@ import sys
import tempfile
import textwrap
import time
+import unittest
from git.compat import string_types, is_win
from git.util import rmtree, cwd
@@ -23,11 +24,6 @@ import gitdb
import os.path as osp
-if sys.version_info[0:2] == (2, 6):
- import unittest2 as unittest
-else:
- import unittest
-
TestCase = unittest.TestCase
SkipTest = unittest.SkipTest
skipIf = unittest.skipIf
@@ -348,7 +344,6 @@ class TestBase(TestCase):
of the project history ( to assure tests don't fail for others ).
"""
- # On py26, unittest2 has assertRaisesRegex
# On py3, unittest has assertRaisesRegex
# On py27, we use unittest, which names it differently:
if sys.version_info[0:2] == (2, 7):
diff --git a/git/test/performance/test_odb.py b/git/test/performance/test_odb.py
index 425af84a..8bd614f2 100644
--- a/git/test/performance/test_odb.py
+++ b/git/test/performance/test_odb.py
@@ -28,11 +28,11 @@ class TestObjDBPerformance(TestBigRepoR):
# GET TREES
# walk all trees of all commits
st = time()
- blobs_per_commit = list()
+ blobs_per_commit = []
nt = 0
for commit in commits:
tree = commit.tree
- blobs = list()
+ blobs = []
for item in tree.traverse():
nt += 1
if item.type == 'blob':
diff --git a/git/test/performance/test_streams.py b/git/test/performance/test_streams.py
index 3909d8ff..2e3772a0 100644
--- a/git/test/performance/test_streams.py
+++ b/git/test/performance/test_streams.py
@@ -69,7 +69,7 @@ class TestObjDBPerformance(TestBigRepoR):
# reading in chunks of 1 MiB
cs = 512 * 1000
- chunks = list()
+ chunks = []
st = time()
ostream = ldb.stream(binsha)
while True:
diff --git a/git/test/test_base.py b/git/test/test_base.py
index 69f161be..2132806b 100644
--- a/git/test/test_base.py
+++ b/git/test/test_base.py
@@ -7,10 +7,7 @@
import os
import sys
import tempfile
-try:
- from unittest import SkipTest, skipIf
-except ImportError:
- from unittest2 import SkipTest, skipIf
+from unittest import SkipTest, skipIf
from git import (
Blob,
diff --git a/git/test/test_diff.py b/git/test/test_diff.py
index 48a5a641..d21dde62 100644
--- a/git/test/test_diff.py
+++ b/git/test/test_diff.py
@@ -217,7 +217,7 @@ class TestDiff(TestBase):
def test_diff_interface(self):
# test a few variations of the main diff routine
- assertion_map = dict()
+ assertion_map = {}
for i, commit in enumerate(self.rorepo.iter_commits('0.1.6', max_count=2)):
diff_item = commit
if i % 2 == 0:
diff --git a/git/test/test_docs.py b/git/test/test_docs.py
index 1ba3f482..67ffb934 100644
--- a/git/test/test_docs.py
+++ b/git/test/test_docs.py
@@ -173,7 +173,7 @@ class Tutorials(TestBase):
# [14-test_init_repo_object]
# create a new submodule and check it out on the spot, setup to track master branch of `bare_repo`
- # As our GitPython repository has submodules already that point to github, make sure we don't
+ # As our GitPython repository has submodules already that point to GitHub, make sure we don't
# interact with them
for sm in cloned_repo.submodules:
assert not sm.remove().exists() # after removal, the sm doesn't exist anymore
diff --git a/git/test/test_fun.py b/git/test/test_fun.py
index 5e32a1f9..314fb734 100644
--- a/git/test/test_fun.py
+++ b/git/test/test_fun.py
@@ -2,11 +2,7 @@ from io import BytesIO
from stat import S_IFDIR, S_IFREG, S_IFLNK
from os import stat
import os.path as osp
-
-try:
- from unittest import skipIf, SkipTest
-except ImportError:
- from unittest2 import skipIf, SkipTest
+from unittest import skipIf, SkipTest
from git import Git
from git.compat import PY3
@@ -215,7 +211,7 @@ class TestFun(TestBase):
def _assert_tree_entries(self, entries, num_trees):
for entry in entries:
assert len(entry) == num_trees
- paths = set(e[2] for e in entry if e)
+ paths = {e[2] for e in entry if e}
# only one path per set of entries
assert len(paths) == 1
diff --git a/git/test/test_git.py b/git/test/test_git.py
index 059f90c0..c6180f7c 100644
--- a/git/test/test_git.py
+++ b/git/test/test_git.py
@@ -91,7 +91,7 @@ class TestGit(TestBase):
# order is undefined
res = self.git.transform_kwargs(**{'s': True, 't': True})
- self.assertEqual(set(['-s', '-t']), set(res))
+ self.assertEqual({'-s', '-t'}, set(res))
def test_it_executes_git_to_shell_and_returns_result(self):
assert_match(r'^git version [\d\.]{2}.*$', self.git.execute(["git", "version"]))
diff --git a/git/test/test_index.py b/git/test/test_index.py
index 757bec9f..9be4031d 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,
@@ -101,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:
@@ -131,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()
@@ -145,14 +141,14 @@ 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)
# 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
@@ -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"
@@ -199,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
@@ -235,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
@@ -536,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)
@@ -891,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):
diff --git a/git/test/test_refs.py b/git/test/test_refs.py
index f885617e..348c3d48 100644
--- a/git/test/test_refs.py
+++ b/git/test/test_refs.py
@@ -45,7 +45,7 @@ class TestRefs(TestBase):
TagReference(self.rorepo, "refs/invalid/tag", check_path=False)
def test_tag_base(self):
- tag_object_refs = list()
+ tag_object_refs = []
for tag in self.rorepo.tags:
assert "refs/tags" in tag.path
assert tag.name
diff --git a/git/test/test_remote.py b/git/test/test_remote.py
index ad9210f6..7c1711c2 100644
--- a/git/test/test_remote.py
+++ b/git/test/test_remote.py
@@ -6,10 +6,7 @@
import random
import tempfile
-try:
- from unittest import skipIf
-except ImportError:
- from unittest2 import skipIf
+from unittest import skipIf
from git import (
RemoteProgress,
@@ -47,8 +44,8 @@ class TestRemoteProgress(RemoteProgress):
def __init__(self):
super(TestRemoteProgress, self).__init__()
- self._seen_lines = list()
- self._stages_per_op = dict()
+ self._seen_lines = []
+ self._stages_per_op = {}
self._num_progress_messages = 0
def _parse_progress_line(self, line):
diff --git a/git/test/test_repo.py b/git/test/test_repo.py
index 2c3ad957..97eac4ae 100644
--- a/git/test/test_repo.py
+++ b/git/test/test_repo.py
@@ -9,12 +9,8 @@ from io import BytesIO
import itertools
import os
import pickle
-import sys
import tempfile
-try:
- from unittest import skipIf, SkipTest
-except ImportError:
- from unittest2 import skipIf, SkipTest
+from unittest import skipIf, SkipTest
try:
import pathlib
@@ -364,9 +360,6 @@ class TestRepo(TestBase):
@patch.object(Git, '_call_process')
def test_should_display_blame_information(self, git):
- if sys.version_info < (2, 7):
- ## Skipped, not `assertRaisesRegexp` in py2.6
- return
git.return_value = fixture('blame')
b = self.rorepo.blame('master', 'lib/git.py')
assert_equal(13, len(b))
@@ -522,7 +515,7 @@ class TestRepo(TestBase):
# this is only a preliminary test, more testing done in test_index
self.assertEqual(self.rorepo, self.rorepo)
self.assertFalse(self.rorepo != self.rorepo)
- self.assertEqual(len(set((self.rorepo, self.rorepo))), 1)
+ self.assertEqual(len({self.rorepo, self.rorepo}), 1)
@with_rw_directory
def test_tilde_and_env_vars_in_repo_path(self, rw_dir):
@@ -792,8 +785,6 @@ class TestRepo(TestBase):
def test_repo_odbtype(self):
target_type = GitCmdObjectDB
- if sys.version_info[:2] < (2, 5):
- target_type = GitCmdObjectDB
self.assertIsInstance(self.rorepo.odb, target_type)
def test_submodules(self):
diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py
index 5c8a2798..0bf76380 100644
--- a/git/test/test_submodule.py
+++ b/git/test/test_submodule.py
@@ -3,10 +3,7 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
import os
import sys
-try:
- from unittest import skipIf
-except ImportError:
- from unittest2 import skipIf
+from unittest import skipIf
import git
from git.cmd import Git
@@ -267,7 +264,7 @@ class TestSubmodule(TestBase):
self.failUnlessRaises(ValueError, csm.remove, module=False, configuration=False)
# module() is supposed to point to gitdb, which has a child-submodule whose URL is still pointing
- # to github. To save time, we will change it to
+ # to GitHub. To save time, we will change it to
csm.set_parent_commit(csm.repo.head.commit)
with csm.config_writer() as cw:
cw.set_value('url', self._small_repo_url())
diff --git a/git/test/test_tree.py b/git/test/test_tree.py
index 5fd4d760..dc23f29c 100644
--- a/git/test/test_tree.py
+++ b/git/test/test_tree.py
@@ -6,10 +6,7 @@
from io import BytesIO
import sys
-try:
- from unittest import skipIf
-except ImportError:
- from unittest2 import skipIf
+from unittest import skipIf
from git import (
Tree,
@@ -64,7 +61,7 @@ class TestTree(TestBase):
def test_traverse(self):
root = self.rorepo.tree('0.1.6')
num_recursive = 0
- all_items = list()
+ all_items = []
for obj in root.traverse():
if "/" in obj.path:
num_recursive += 1
@@ -82,7 +79,7 @@ class TestTree(TestBase):
# only choose trees
trees_only = lambda i, d: i.type == "tree"
trees = list(root.traverse(predicate=trees_only))
- assert len(trees) == len(list(i for i in root.traverse() if trees_only(i, 0)))
+ assert len(trees) == len([i for i in root.traverse() if trees_only(i, 0)])
# test prune
lib_folder = lambda t, d: t.path == "lib"
@@ -91,7 +88,7 @@ class TestTree(TestBase):
# trees and blobs
assert len(set(trees) | set(root.trees)) == len(trees)
- assert len(set(b for b in root if isinstance(b, Blob)) | set(root.blobs)) == len(root.blobs)
+ assert len({b for b in root if isinstance(b, Blob)} | set(root.blobs)) == len(root.blobs)
subitem = trees[0][0]
assert "/" in subitem.path
assert subitem.name == osp.basename(subitem.path)
diff --git a/git/test/test_util.py b/git/test/test_util.py
index d30c8376..b7925c84 100644
--- a/git/test/test_util.py
+++ b/git/test/test_util.py
@@ -6,10 +6,7 @@
import tempfile
import time
-try:
- from unittest import skipIf
-except ImportError:
- from unittest2 import skipIf
+from unittest import skipIf
import ddt