This repository was archived by the owner on Apr 14, 2024. It is now read-only.
File tree 6 files changed +43
-41
lines changed
6 files changed +43
-41
lines changed Original file line number Diff line number Diff line change @@ -12,32 +12,34 @@ class ODBError(Exception):
12
12
13
13
14
14
class InvalidDBRoot (ODBError ):
15
-
16
15
"""Thrown if an object database cannot be initialized at the given path"""
17
16
18
17
19
18
class BadObject (ODBError ):
20
-
21
19
"""The object with the given SHA does not exist. Instantiate with the
22
20
failed sha"""
23
21
24
22
def __str__ (self ):
25
23
return "BadObject: %s" % to_hex_sha (self .args [0 ])
26
24
27
25
28
- class ParseError (ODBError ):
26
+ class BadName (ODBError ):
27
+ """A name provided to rev_parse wasn't understood"""
28
+
29
+ def __str__ (self ):
30
+ return "Ref '%s' did not resolve to an object" % self .args [0 ]
29
31
32
+
33
+ class ParseError (ODBError ):
30
34
"""Thrown if the parsing of a file failed due to an invalid format"""
31
35
32
36
33
37
class AmbiguousObjectName (ODBError ):
34
-
35
38
"""Thrown if a possibly shortened name does not uniquely represent a single object
36
39
in the database"""
37
40
38
41
39
42
class BadObjectType (ODBError ):
40
-
41
43
"""The object had an unsupported type"""
42
44
43
45
Original file line number Diff line number Diff line change 2
2
#
3
3
# This module is part of GitDB and is released under
4
4
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
5
+ import os
5
6
from gitdb .test .db .lib import (
6
7
TestDBBase ,
7
8
fixture_path ,
16
17
class TestGitDB (TestDBBase ):
17
18
18
19
def test_reading (self ):
19
- gdb = GitDB (fixture_path ( '../../../.git/ objects' ))
20
+ gdb = GitDB (os . path . join ( self . gitrepopath , ' objects' ))
20
21
21
22
# we have packs and loose objects, alternates doesn't necessarily exist
22
23
assert 1 < len (gdb .databases ()) < 4
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ def test_writing(self, path):
40
40
41
41
# setup alternate file
42
42
# add two, one is invalid
43
- own_repo_path = fixture_path ( '../../../.git/ objects' ) # use own repo
43
+ own_repo_path = os . path . join ( self . gitrepopath , ' objects' ) # use own repo
44
44
self .make_alt_file (alt_path , [own_repo_path , "invalid/path" ])
45
45
rdb .update_cache ()
46
46
assert len (rdb .databases ()) == 1
Original file line number Diff line number Diff line change 18
18
import shutil
19
19
import os
20
20
import gc
21
+ import logging
21
22
from functools import wraps
22
23
23
24
24
25
#{ Bases
25
26
26
27
class TestBase (unittest .TestCase ):
28
+ """Base class for all tests
27
29
28
- """Base class for all tests"""
30
+ TestCase providing access to readonly repositories using the following member variables.
31
+
32
+ * gitrepopath
33
+
34
+ * read-only base path of the git source repository, i.e. .../git/.git
35
+ """
36
+
37
+ #{ Invvariants
38
+ k_env_git_repo = "GITDB_TEST_GIT_REPO_BASE"
39
+ #} END invariants
40
+
41
+ @classmethod
42
+ def setUpClass (cls ):
43
+ try :
44
+ super (TestBase , cls ).setUpClass ()
45
+ except AttributeError :
46
+ pass
47
+
48
+ cls .gitrepopath = os .environ .get (cls .k_env_git_repo )
49
+ if not cls .gitrepopath :
50
+ logging .info (
51
+ "You can set the %s environment variable to a .git repository of your choice - defaulting to the gitdb repository" , cls .k_env_git_repo )
52
+ ospd = os .path .dirname
53
+ cls .gitrepopath = os .path .join (ospd (ospd (ospd (__file__ ))), '.git' )
54
+ # end assure gitrepo is set
55
+ assert cls .gitrepopath .endswith ('.git' )
29
56
30
57
31
58
#} END bases
Original file line number Diff line number Diff line change 3
3
# This module is part of GitDB and is released under
4
4
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
5
5
"""Contains library functions"""
6
- import os
7
- import logging
8
6
from gitdb .test .lib import TestBase
9
7
10
8
11
- #{ Invvariants
12
- k_env_git_repo = "GITDB_TEST_GIT_REPO_BASE"
13
- #} END invariants
14
-
15
9
16
10
#{ Base Classes
17
11
18
12
class TestBigRepoR (TestBase ):
19
-
20
- """TestCase providing access to readonly 'big' repositories using the following
21
- member variables:
22
-
23
- * gitrepopath
24
-
25
- * read-only base path of the git source repository, i.e. .../git/.git"""
26
-
27
- def setUp (self ):
28
- try :
29
- super (TestBigRepoR , self ).setUp ()
30
- except AttributeError :
31
- pass
32
-
33
- self .gitrepopath = os .environ .get (k_env_git_repo )
34
- if not self .gitrepopath :
35
- logging .info (
36
- "You can set the %s environment variable to a .git repository of your choice - defaulting to the gitdb repository" , k_env_git_repo )
37
- ospd = os .path .dirname
38
- self .gitrepopath = os .path .join (ospd (ospd (ospd (ospd (__file__ )))), '.git' )
39
- # end assure gitrepo is set
40
- assert self .gitrepopath .endswith ('.git' )
13
+ """A placeholder in case we want to add additional functionality to all performance test-cases
14
+ """
41
15
42
16
43
17
#} END base classes
Original file line number Diff line number Diff line change 3
3
# This module is part of GitDB and is released under
4
4
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
5
5
"""Module with examples from the tutorial section of the docs"""
6
- from gitdb .test .lib import (
7
- TestBase ,
8
- fixture_path
9
- )
6
+ import os
7
+ from gitdb .test .lib import TestBase
10
8
from gitdb import IStream
11
9
from gitdb .db import LooseObjectDB
12
10
16
14
class TestExamples (TestBase ):
17
15
18
16
def test_base (self ):
19
- ldb = LooseObjectDB (fixture_path ( "../../../.git/ objects" ))
17
+ ldb = LooseObjectDB (os . path . join ( self . gitrepopath , ' objects' ))
20
18
21
19
for sha1 in ldb .sha_iter ():
22
20
oinfo = ldb .info (sha1 )
You can’t perform that action at this time.
0 commit comments