Skip to content

Commit a88a777

Browse files
committed
Make tests independent of actual repository data
Therefore, hardcoded sha's are not allowed anymore, as the contents of the repository is unknown. Fixes #16, for real this time ;)
1 parent f2233fb commit a88a777

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

gitdb/test/db/test_git.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from gitdb.exc import BadObject
1111
from gitdb.db import GitDB
1212
from gitdb.base import OStream, OInfo
13-
from gitdb.util import hex_to_bin, bin_to_hex
13+
from gitdb.util import bin_to_hex
1414

1515

1616
class TestGitDB(TestDBBase):
@@ -22,7 +22,7 @@ def test_reading(self):
2222
assert 1 < len(gdb.databases()) < 4
2323

2424
# access should be possible
25-
gitdb_sha = hex_to_bin("5690fd0d3304f378754b23b098bd7cb5f4aa1976")
25+
gitdb_sha = next(gdb.sha_iter())
2626
assert isinstance(gdb.info(gitdb_sha), OInfo)
2727
assert isinstance(gdb.stream(gitdb_sha), OStream)
2828
ni = 50
@@ -35,7 +35,8 @@ def test_reading(self):
3535
# have a separate test module
3636
# test partial shas
3737
# this one as uneven and quite short
38-
assert gdb.partial_to_complete_sha_hex('155b6') == hex_to_bin("155b62a9af0aa7677078331e111d0f7aa6eb4afc")
38+
gitdb_sha_hex = bin_to_hex(gitdb_sha)
39+
assert gdb.partial_to_complete_sha_hex(gitdb_sha_hex[:5]) == gitdb_sha
3940

4041
# mix even/uneven hexshas
4142
for i, binsha in enumerate(sha_list):

gitdb/test/db/test_ref.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_writing(self, path):
4545
assert len(rdb.databases()) == 1
4646

4747
# we should now find a default revision of ours
48-
gitdb_sha = hex_to_bin("5690fd0d3304f378754b23b098bd7cb5f4aa1976")
48+
gitdb_sha = next(rdb.sha_iter())
4949
assert rdb.has_object(gitdb_sha)
5050

5151
# remove valid

0 commit comments

Comments
 (0)