This repository was archived by the owner on Apr 14, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +43
-41
lines changed Expand file tree Collapse file tree 6 files changed +43
-41
lines changed Original file line number Diff line number Diff line change @@ -12,32 +12,34 @@ class ODBError(Exception):
1212
1313
1414class InvalidDBRoot (ODBError ):
15-
1615 """Thrown if an object database cannot be initialized at the given path"""
1716
1817
1918class BadObject (ODBError ):
20-
2119 """The object with the given SHA does not exist. Instantiate with the
2220 failed sha"""
2321
2422 def __str__ (self ):
2523 return "BadObject: %s" % to_hex_sha (self .args [0 ])
2624
2725
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 ]
2931
32+
33+ class ParseError (ODBError ):
3034 """Thrown if the parsing of a file failed due to an invalid format"""
3135
3236
3337class AmbiguousObjectName (ODBError ):
34-
3538 """Thrown if a possibly shortened name does not uniquely represent a single object
3639 in the database"""
3740
3841
3942class BadObjectType (ODBError ):
40-
4143 """The object had an unsupported type"""
4244
4345
Original file line number Diff line number Diff line change 22#
33# This module is part of GitDB and is released under
44# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
5+ import os
56from gitdb .test .db .lib import (
67 TestDBBase ,
78 fixture_path ,
1617class TestGitDB (TestDBBase ):
1718
1819 def test_reading (self ):
19- gdb = GitDB (fixture_path ( '../../../.git/ objects' ))
20+ gdb = GitDB (os . path . join ( self . gitrepopath , ' objects' ))
2021
2122 # we have packs and loose objects, alternates doesn't necessarily exist
2223 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):
4040
4141 # setup alternate file
4242 # 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
4444 self .make_alt_file (alt_path , [own_repo_path , "invalid/path" ])
4545 rdb .update_cache ()
4646 assert len (rdb .databases ()) == 1
Original file line number Diff line number Diff line change 1818import shutil
1919import os
2020import gc
21+ import logging
2122from functools import wraps
2223
2324
2425#{ Bases
2526
2627class TestBase (unittest .TestCase ):
28+ """Base class for all tests
2729
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' )
2956
3057
3158#} END bases
Original file line number Diff line number Diff line change 33# This module is part of GitDB and is released under
44# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
55"""Contains library functions"""
6- import os
7- import logging
86from gitdb .test .lib import TestBase
97
108
11- #{ Invvariants
12- k_env_git_repo = "GITDB_TEST_GIT_REPO_BASE"
13- #} END invariants
14-
159
1610#{ Base Classes
1711
1812class 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+ """
4115
4216
4317#} END base classes
Original file line number Diff line number Diff line change 33# This module is part of GitDB and is released under
44# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
55"""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
108from gitdb import IStream
119from gitdb .db import LooseObjectDB
1210
1614class TestExamples (TestBase ):
1715
1816 def test_base (self ):
19- ldb = LooseObjectDB (fixture_path ( "../../../.git/ objects" ))
17+ ldb = LooseObjectDB (os . path . join ( self . gitrepopath , ' objects' ))
2018
2119 for sha1 in ldb .sha_iter ():
2220 oinfo = ldb .info (sha1 )
You can’t perform that action at this time.
0 commit comments