diff options
Diffstat (limited to 'git')
-rw-r--r-- | git/exc.py | 22 | ||||
-rw-r--r-- | git/refs/log.py | 14 | ||||
-rw-r--r-- | git/test/test_base.py | 2 | ||||
-rw-r--r-- | git/test/test_commit.py | 10 | ||||
-rw-r--r-- | git/test/test_diff.py | 48 | ||||
-rw-r--r-- | git/test/test_git.py | 4 | ||||
-rw-r--r-- | git/test/test_index.py | 24 | ||||
-rw-r--r-- | git/test/test_repo.py | 8 | ||||
-rw-r--r-- | git/util.py | 2 |
9 files changed, 67 insertions, 67 deletions
@@ -34,8 +34,8 @@ class CommandError(GitError): #: A unicode print-format with 2 `%s for `<cmdline>` and the rest, #: e.g. - #: u"'%s' failed%s" - _msg = u"Cmd('%s') failed%s" + #: "'%s' failed%s" + _msg = "Cmd('%s') failed%s" def __init__(self, command, status=None, stderr=None, stdout=None): if not isinstance(command, (tuple, list)): @@ -44,19 +44,19 @@ class CommandError(GitError): self.status = status if status: if isinstance(status, Exception): - status = u"%s('%s')" % (type(status).__name__, safe_decode(str(status))) + status = "%s('%s')" % (type(status).__name__, safe_decode(str(status))) else: try: - status = u'exit code(%s)' % int(status) + status = 'exit code(%s)' % int(status) except (ValueError, TypeError): s = safe_decode(str(status)) - status = u"'%s'" % s if isinstance(status, str) else s + status = "'%s'" % s if isinstance(status, str) else s self._cmd = safe_decode(command[0]) - self._cmdline = u' '.join(safe_decode(i) for i in command) - self._cause = status and u" due to: %s" % status or "!" - self.stdout = stdout and u"\n stdout: '%s'" % safe_decode(stdout) or '' - self.stderr = stderr and u"\n stderr: '%s'" % safe_decode(stderr) or '' + self._cmdline = ' '.join(safe_decode(i) for i in command) + self._cause = status and " due to: %s" % status or "!" + self.stdout = stdout and "\n stdout: '%s'" % safe_decode(stdout) or '' + self.stderr = stderr and "\n stderr: '%s'" % safe_decode(stderr) or '' def __str__(self): return (self._msg + "\n cmdline: %s%s%s") % ( @@ -68,7 +68,7 @@ class GitCommandNotFound(CommandError): the GIT_PYTHON_GIT_EXECUTABLE environment variable""" def __init__(self, command, cause): super(GitCommandNotFound, self).__init__(command, cause) - self._msg = u"Cmd('%s') not found%s" + self._msg = "Cmd('%s') not found%s" class GitCommandError(CommandError): @@ -118,7 +118,7 @@ class HookExecutionError(CommandError): def __init__(self, command, status, stderr=None, stdout=None): super(HookExecutionError, self).__init__(command, status, stderr, stdout) - self._msg = u"Hook('%s') failed%s" + self._msg = "Hook('%s') failed%s" class RepositoryDirtyError(GitError): diff --git a/git/refs/log.py b/git/refs/log.py index 965b26c7..fcd2c23c 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -37,13 +37,13 @@ class RefLogEntry(tuple): """:return: a string suitable to be placed in a reflog file""" act = self.actor time = self.time - return u"{} {} {} <{}> {!s} {}\t{}\n".format(self.oldhexsha, - self.newhexsha, - act.name, - act.email, - time[0], - altz_to_utctz_str(time[1]), - self.message) + return "{} {} {} <{}> {!s} {}\t{}\n".format(self.oldhexsha, + self.newhexsha, + act.name, + act.email, + time[0], + altz_to_utctz_str(time[1]), + self.message) @property def oldhexsha(self): diff --git a/git/test/test_base.py b/git/test/test_base.py index ee2e8e07..9cbbcf23 100644 --- a/git/test/test_base.py +++ b/git/test/test_base.py @@ -122,7 +122,7 @@ class TestBase(TestBase): "Unicode woes, see https://github.com/gitpython-developers/GitPython/pull/519") @with_rw_repo('0.1.6') def test_add_unicode(self, rw_repo): - filename = u"שלום.txt" + filename = "שלום.txt" file_path = osp.join(rw_repo.working_dir, filename) diff --git a/git/test/test_commit.py b/git/test/test_commit.py index 0e94bcb6..2b901e8b 100644 --- a/git/test/test_commit.py +++ b/git/test/test_commit.py @@ -132,9 +132,9 @@ class TestCommit(TestCommitSerialization): def test_unicode_actor(self): # assure we can parse unicode actors correctly - name = u"Üäöß ÄußÉ" + name = "Üäöß ÄußÉ" self.assertEqual(len(name), 9) - special = Actor._from_string(u"%s <something@this.com>" % name) + special = Actor._from_string("%s <something@this.com>" % name) self.assertEqual(special.name, name) assert isinstance(special.name, str) @@ -283,10 +283,10 @@ class TestCommit(TestCommitSerialization): assert isinstance(cmt.message, str) # it automatically decodes it as such assert isinstance(cmt.author.name, str) # same here - cmt.message = u"üäêèß" + cmt.message = "üäêèß" self.assertEqual(len(cmt.message), 5) - cmt.author.name = u"äüß" + cmt.author.name = "äüß" self.assertEqual(len(cmt.author.name), 3) cstream = BytesIO() @@ -308,7 +308,7 @@ class TestCommit(TestCommitSerialization): with open(fixture_path('commit_invalid_data'), 'rb') as fd: cmt._deserialize(fd) - self.assertEqual(cmt.author.name, u'E.Azer Ko�o�o�oculu', cmt.author.name) + self.assertEqual(cmt.author.name, 'E.Azer Ko�o�o�oculu', cmt.author.name) self.assertEqual(cmt.author.email, 'azer@kodfabrik.com', cmt.author.email) def test_gpgsig(self): diff --git a/git/test/test_diff.py b/git/test/test_diff.py index 41907a91..0b4c1aa6 100644 --- a/git/test/test_diff.py +++ b/git/test/test_diff.py @@ -106,8 +106,8 @@ class TestDiff(TestBase): diff = diffs[0] self.assertTrue(diff.renamed_file) self.assertTrue(diff.renamed) - self.assertEqual(diff.rename_from, u'Jérôme') - self.assertEqual(diff.rename_to, u'müller') + self.assertEqual(diff.rename_from, 'Jérôme') + self.assertEqual(diff.rename_to, 'müller') self.assertEqual(diff.raw_rename_from, b'J\xc3\xa9r\xc3\xb4me') self.assertEqual(diff.raw_rename_to, b'm\xc3\xbcller') assert isinstance(str(diff), str) @@ -133,8 +133,8 @@ class TestDiff(TestBase): diff = diffs[0] self.assertTrue(diff.copied_file) - self.assertTrue(diff.a_path, u'test1.txt') - self.assertTrue(diff.b_path, u'test2.txt') + self.assertTrue(diff.a_path, 'test1.txt') + self.assertTrue(diff.b_path, 'test2.txt') assert isinstance(str(diff), str) output = StringProcessAdapter(fixture('diff_copied_mode_raw')) @@ -143,8 +143,8 @@ class TestDiff(TestBase): diff = diffs[0] self.assertEqual(diff.change_type, 'C') self.assertEqual(diff.score, 100) - self.assertEqual(diff.a_path, u'test1.txt') - self.assertEqual(diff.b_path, u'test2.txt') + self.assertEqual(diff.a_path, 'test1.txt') + self.assertEqual(diff.b_path, 'test2.txt') self.assertEqual(len(list(diffs.iter_change_type('C'))), 1) def test_diff_with_change_in_type(self): @@ -237,29 +237,29 @@ class TestDiff(TestBase): res = Diff._index_from_patch_format(None, output) # The "Additions" - self.assertEqual(res[0].b_path, u'path/ starting with a space') - self.assertEqual(res[1].b_path, u'path/"with-quotes"') - self.assertEqual(res[2].b_path, u"path/'with-single-quotes'") - self.assertEqual(res[3].b_path, u'path/ending in a space ') - self.assertEqual(res[4].b_path, u'path/with\ttab') - self.assertEqual(res[5].b_path, u'path/with\nnewline') - self.assertEqual(res[6].b_path, u'path/with spaces') - self.assertEqual(res[7].b_path, u'path/with-question-mark?') - self.assertEqual(res[8].b_path, u'path/¯\\_(ツ)_|¯') - self.assertEqual(res[9].b_path, u'path/💩.txt') + self.assertEqual(res[0].b_path, 'path/ starting with a space') + self.assertEqual(res[1].b_path, 'path/"with-quotes"') + self.assertEqual(res[2].b_path, "path/'with-single-quotes'") + self.assertEqual(res[3].b_path, 'path/ending in a space ') + self.assertEqual(res[4].b_path, 'path/with\ttab') + self.assertEqual(res[5].b_path, 'path/with\nnewline') + self.assertEqual(res[6].b_path, 'path/with spaces') + self.assertEqual(res[7].b_path, 'path/with-question-mark?') + self.assertEqual(res[8].b_path, 'path/¯\\_(ツ)_|¯') + self.assertEqual(res[9].b_path, 'path/💩.txt') self.assertEqual(res[9].b_rawpath, b'path/\xf0\x9f\x92\xa9.txt') - self.assertEqual(res[10].b_path, u'path/�-invalid-unicode-path.txt') + self.assertEqual(res[10].b_path, 'path/�-invalid-unicode-path.txt') self.assertEqual(res[10].b_rawpath, b'path/\x80-invalid-unicode-path.txt') # The "Moves" # NOTE: The path prefixes a/ and b/ here are legit! We're actually # verifying that it's not "a/a/" that shows up, see the fixture data. - self.assertEqual(res[11].a_path, u'a/with spaces') # NOTE: path a/ here legit! - self.assertEqual(res[11].b_path, u'b/with some spaces') # NOTE: path b/ here legit! - self.assertEqual(res[12].a_path, u'a/ending in a space ') - self.assertEqual(res[12].b_path, u'b/ending with space ') - self.assertEqual(res[13].a_path, u'a/"with-quotes"') - self.assertEqual(res[13].b_path, u'b/"with even more quotes"') + self.assertEqual(res[11].a_path, 'a/with spaces') # NOTE: path a/ here legit! + self.assertEqual(res[11].b_path, 'b/with some spaces') # NOTE: path b/ here legit! + self.assertEqual(res[12].a_path, 'a/ending in a space ') + self.assertEqual(res[12].b_path, 'b/ending with space ') + self.assertEqual(res[13].a_path, 'a/"with-quotes"') + self.assertEqual(res[13].b_path, 'b/"with even more quotes"') def test_diff_patch_format(self): # test all of the 'old' format diffs for completness - it should at least @@ -277,7 +277,7 @@ class TestDiff(TestBase): data = StringProcessAdapter(fixture('diff_file_with_spaces')) diff_index = Diff._index_from_patch_format(self.rorepo, data) self.assertIsNone(diff_index[0].a_path, repr(diff_index[0].a_path)) - self.assertEqual(diff_index[0].b_path, u'file with spaces', repr(diff_index[0].b_path)) + self.assertEqual(diff_index[0].b_path, 'file with spaces', repr(diff_index[0].b_path)) def test_diff_submodule(self): """Test that diff is able to correctly diff commits that cover submodule changes""" diff --git a/git/test/test_git.py b/git/test/test_git.py index 060a4c3c..1e3cac8f 100644 --- a/git/test/test_git.py +++ b/git/test/test_git.py @@ -50,12 +50,12 @@ class TestGit(TestBase): self.assertEqual(git.call_args, ((['git', 'version'],), {})) def test_call_unpack_args_unicode(self): - args = Git._Git__unpack_args(u'Unicode€™') + args = Git._Git__unpack_args('Unicode€™') mangled_value = 'Unicode\u20ac\u2122' self.assertEqual(args, [mangled_value]) def test_call_unpack_args(self): - args = Git._Git__unpack_args(['git', 'log', '--', u'Unicode€™']) + args = Git._Git__unpack_args(['git', 'log', '--', 'Unicode€™']) mangled_value = 'Unicode\u20ac\u2122' self.assertEqual(args, ['git', 'log', '--', mangled_value]) diff --git a/git/test/test_index.py b/git/test/test_index.py index 355cd87e..3575348a 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -429,7 +429,7 @@ class TestIndex(TestBase): num_entries = len(index.entries) cur_head = rw_repo.head - uname = u"Thomas Müller" + uname = "Thomas Müller" umail = "sd@company.com" with rw_repo.config_writer() as writer: writer.set_value("user", "name", uname) @@ -484,7 +484,7 @@ class TestIndex(TestBase): # TEST COMMITTING # commit changed index cur_commit = cur_head.commit - commit_message = u"commit default head by Frèderic Çaufl€" + commit_message = "commit default head by Frèderic Çaufl€" new_commit = index.commit(commit_message, head=False) assert cur_commit != new_commit @@ -500,13 +500,13 @@ class TestIndex(TestBase): # commit with other actor cur_commit = cur_head.commit - my_author = Actor(u"Frèderic Çaufl€", "author@example.com") - my_committer = Actor(u"Committing Frèderic Çaufl€", "committer@example.com") + my_author = Actor("Frèderic Çaufl€", "author@example.com") + my_committer = Actor("Committing Frèderic Çaufl€", "committer@example.com") commit_actor = index.commit(commit_message, author=my_author, committer=my_committer) assert cur_commit != commit_actor - self.assertEqual(commit_actor.author.name, u"Frèderic Çaufl€") + self.assertEqual(commit_actor.author.name, "Frèderic Çaufl€") self.assertEqual(commit_actor.author.email, "author@example.com") - self.assertEqual(commit_actor.committer.name, u"Committing Frèderic Çaufl€") + self.assertEqual(commit_actor.committer.name, "Committing Frèderic Çaufl€") self.assertEqual(commit_actor.committer.email, "committer@example.com") self.assertEqual(commit_actor.message, commit_message) self.assertEqual(commit_actor.parents[0], cur_commit) @@ -516,7 +516,7 @@ class TestIndex(TestBase): # commit with author_date and commit_date cur_commit = cur_head.commit - commit_message = u"commit with dates by Avinash Sajjanshetty" + commit_message = "commit with dates by Avinash Sajjanshetty" new_commit = index.commit(commit_message, author_date="2006-04-07T22:13:13", commit_date="2005-04-07T22:13:13") assert cur_commit != new_commit @@ -777,7 +777,7 @@ class TestIndex(TestBase): def test_index_single_addremove(self, rw_repo): fp = osp.join(rw_repo.working_dir, 'testfile.txt') with open(fp, 'w') as fs: - fs.write(u'content of testfile') + fs.write('content of testfile') self._assert_entries(rw_repo.index.add(fp)) deleted_files = rw_repo.index.remove(fp) assert deleted_files @@ -826,7 +826,7 @@ class TestIndex(TestBase): # NOTE: fp is not a Unicode object in python 2 (which is the source of the problem) fp = osp.join(rw_dir, 'ø.txt') with open(fp, 'wb') as fs: - fs.write(u'content of ø'.encode('utf-8')) + fs.write('content of ø'.encode('utf-8')) r = Repo.init(rw_dir) r.index.add([fp]) @@ -896,8 +896,8 @@ class TestIndex(TestBase): @with_rw_repo('HEAD', bare=True) def test_commit_msg_hook_success(self, rw_repo): - commit_message = u"commit default head by Frèderic Çaufl€" - from_hook_message = u"from commit-msg" + commit_message = "commit default head by Frèderic Çaufl€" + from_hook_message = "from commit-msg" index = rw_repo.index _make_hook( index.repo.git_dir, @@ -905,7 +905,7 @@ class TestIndex(TestBase): 'printf " {}" >> "$1"'.format(from_hook_message) ) new_commit = index.commit(commit_message) - self.assertEqual(new_commit.message, u"{} {}".format(commit_message, from_hook_message)) + self.assertEqual(new_commit.message, "{} {}".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_repo.py b/git/test/test_repo.py index 6fcbc17a..590e303e 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -453,7 +453,7 @@ class TestRepo(TestBase): self.assertEqual(commits, ['82b8902', '82b8902', 'c76852d', 'c76852d', 'c76852d']) # Original filenames - self.assertSequenceEqual([entry.orig_path for entry in blame_output], [u'AUTHORS'] * len(blame_output)) + self.assertSequenceEqual([entry.orig_path for entry in blame_output], ['AUTHORS'] * len(blame_output)) # Original line numbers orig_ranges = flatten([entry.orig_linenos for entry in blame_output]) @@ -478,10 +478,10 @@ class TestRepo(TestBase): def test_untracked_files(self, rwrepo): for run, repo_add in enumerate((rwrepo.index.add, rwrepo.git.add)): base = rwrepo.working_tree_dir - files = (join_path_native(base, u"%i_test _myfile" % run), + files = (join_path_native(base, "%i_test _myfile" % run), join_path_native(base, "%i_test_other_file" % run), - join_path_native(base, u"%i__çava verböten" % run), - join_path_native(base, u"%i_çava-----verböten" % run)) + join_path_native(base, "%i__çava verböten" % run), + join_path_native(base, "%i_çava-----verböten" % run)) num_recently_untracked = 0 for fpath in files: diff --git a/git/util.py b/git/util.py index cf0ba8d5..d5939a6f 100644 --- a/git/util.py +++ b/git/util.py @@ -555,7 +555,7 @@ class Actor(object): return self.name def __repr__(self): - return u'<git.Actor "%s <%s>">' % (self.name, self.email) + return '<git.Actor "%s <%s>">' % (self.name, self.email) @classmethod def _from_string(cls, string): |