From 1c6f4c19289732bd13507eba9e54c9d692957137 Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Sun, 13 Jul 2014 15:35:24 -0400 Subject: Automated PEP 8 fixes --- gitdb/test/db/test_ref.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'gitdb/test/db/test_ref.py') diff --git a/gitdb/test/db/test_ref.py b/gitdb/test/db/test_ref.py index 1637bff..0864468 100644 --- a/gitdb/test/db/test_ref.py +++ b/gitdb/test/db/test_ref.py @@ -6,14 +6,14 @@ from lib import * from gitdb.db import ReferenceDB from gitdb.util import ( - NULL_BIN_SHA, - hex_to_bin - ) + NULL_BIN_SHA, + hex_to_bin +) import os - + class TestReferenceDB(TestDBBase): - + def make_alt_file(self, alt_path, alt_list): """Create an alternates file which contains the given alternates. The list can be empty""" @@ -21,40 +21,38 @@ class TestReferenceDB(TestDBBase): for alt in alt_list: alt_file.write(alt + "\n") alt_file.close() - + @with_rw_directory def test_writing(self, path): NULL_BIN_SHA = '\0' * 20 - + alt_path = os.path.join(path, 'alternates') rdb = ReferenceDB(alt_path) assert len(rdb.databases()) == 0 assert rdb.size() == 0 assert len(list(rdb.sha_iter())) == 0 - + # try empty, non-existing assert not rdb.has_object(NULL_BIN_SHA) - - + + # setup alternate file # add two, one is invalid own_repo_path = fixture_path('../../../.git/objects') # use own repo self.make_alt_file(alt_path, [own_repo_path, "invalid/path"]) rdb.update_cache() assert len(rdb.databases()) == 1 - + # we should now find a default revision of ours gitdb_sha = hex_to_bin("5690fd0d3304f378754b23b098bd7cb5f4aa1976") assert rdb.has_object(gitdb_sha) - + # remove valid self.make_alt_file(alt_path, ["just/one/invalid/path"]) rdb.update_cache() assert len(rdb.databases()) == 0 - + # add valid self.make_alt_file(alt_path, [own_repo_path]) rdb.update_cache() assert len(rdb.databases()) == 1 - - -- cgit v1.2.1 From b6c493deb2341fb843d71b66b2aa23078638755c Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Sun, 13 Jul 2014 15:41:15 -0400 Subject: Pick off the low hanging fruit This fixes most of the import errors that came from using the implicit relative imports that Python 2 supports. This also fixes the use of `xrange`, which has replaced `range` in Python 3. The same has happened for `izip`, which is also being aliased. The octal number syntax changed in Python 3, so we are now converting from strings using the `int` built-in function, which will produce the same output across both versions of Python. --- gitdb/test/db/test_ref.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gitdb/test/db/test_ref.py') diff --git a/gitdb/test/db/test_ref.py b/gitdb/test/db/test_ref.py index 0864468..752c31d 100644 --- a/gitdb/test/db/test_ref.py +++ b/gitdb/test/db/test_ref.py @@ -2,7 +2,7 @@ # # This module is part of GitDB and is released under # the New BSD License: http://www.opensource.org/licenses/bsd-license.php -from lib import * +from gitdb.test.db.lib import * from gitdb.db import ReferenceDB from gitdb.util import ( -- cgit v1.2.1 From d8405ee00bfc1ebdae7c41b45f8c374902a3d2b4 Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Sun, 13 Jul 2014 19:55:00 -0400 Subject: More bytes handling --- gitdb/test/db/test_ref.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gitdb/test/db/test_ref.py') diff --git a/gitdb/test/db/test_ref.py b/gitdb/test/db/test_ref.py index 752c31d..e303fe2 100644 --- a/gitdb/test/db/test_ref.py +++ b/gitdb/test/db/test_ref.py @@ -19,7 +19,7 @@ class TestReferenceDB(TestDBBase): The list can be empty""" alt_file = open(alt_path, "wb") for alt in alt_list: - alt_file.write(alt + "\n") + alt_file.write(alt.encode("utf-8") + "\n".encode("ascii")) alt_file.close() @with_rw_directory -- cgit v1.2.1 From f0b3e7bcc5278208294f40aa580ccb378ed1c165 Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Sun, 13 Jul 2014 20:14:24 -0400 Subject: Bytes for everyone! --- gitdb/test/db/test_ref.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gitdb/test/db/test_ref.py') diff --git a/gitdb/test/db/test_ref.py b/gitdb/test/db/test_ref.py index e303fe2..a1387ee 100644 --- a/gitdb/test/db/test_ref.py +++ b/gitdb/test/db/test_ref.py @@ -24,7 +24,7 @@ class TestReferenceDB(TestDBBase): @with_rw_directory def test_writing(self, path): - NULL_BIN_SHA = '\0' * 20 + NULL_BIN_SHA = '\0'.encode("ascii") * 20 alt_path = os.path.join(path, 'alternates') rdb = ReferenceDB(alt_path) @@ -35,7 +35,6 @@ class TestReferenceDB(TestDBBase): # try empty, non-existing assert not rdb.has_object(NULL_BIN_SHA) - # setup alternate file # add two, one is invalid own_repo_path = fixture_path('../../../.git/objects') # use own repo -- cgit v1.2.1 From 8ae4e9579a263684c6b760aec2869be480ff22ba Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 13 Nov 2014 18:46:49 +0100 Subject: reduced usage of force_bytes as clients are expected to pass bytes. It was useful for debugging though, maybe an explicit type assertions would help others ? As 'others' will be gitpython, I suppose I can handle it myself --- gitdb/test/db/test_ref.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'gitdb/test/db/test_ref.py') diff --git a/gitdb/test/db/test_ref.py b/gitdb/test/db/test_ref.py index a1387ee..db93082 100644 --- a/gitdb/test/db/test_ref.py +++ b/gitdb/test/db/test_ref.py @@ -2,7 +2,11 @@ # # This module is part of GitDB and is released under # the New BSD License: http://www.opensource.org/licenses/bsd-license.php -from gitdb.test.db.lib import * +from gitdb.test.db.lib import ( + TestDBBase, + with_rw_directory, + fixture_path +) from gitdb.db import ReferenceDB from gitdb.util import ( @@ -24,8 +28,6 @@ class TestReferenceDB(TestDBBase): @with_rw_directory def test_writing(self, path): - NULL_BIN_SHA = '\0'.encode("ascii") * 20 - alt_path = os.path.join(path, 'alternates') rdb = ReferenceDB(alt_path) assert len(rdb.databases()) == 0 -- cgit v1.2.1