diff options
Diffstat (limited to 'git/test/lib')
-rw-r--r-- | git/test/lib/base.py | 11 | ||||
-rw-r--r-- | git/test/lib/helper.py | 44 |
2 files changed, 11 insertions, 44 deletions
diff --git a/git/test/lib/base.py b/git/test/lib/base.py index 7bd9215e..bc160783 100644 --- a/git/test/lib/base.py +++ b/git/test/lib/base.py @@ -86,6 +86,7 @@ def with_packs_rw(func): :note: needs with_rw_directory wrapped around it""" def wrapper(self, path): src_pack_glob = fixture_path('packs/*') + print src_pack_glob copy_files_globbed(src_pack_glob, path, hard_link_ok=True) return func(self, path) # END wrapper @@ -103,7 +104,6 @@ def rorepo_dir(): base = os.path.join(dirname(dirname(dirname(dirname(__file__)))), '.git') assert os.path.isdir(base) return base - def maketemp(*args, **kwargs): """Wrapper around default tempfile.mktemp to fix an osx issue""" @@ -116,8 +116,15 @@ def fixture_path(relapath=''): """:return: absolute path into the fixture directory :param relapath: relative path into the fixtures directory, or '' to obtain the fixture directory itself""" - return os.path.join(dirname(__file__), 'fixtures', relapath) + test_dir = os.path.dirname(os.path.dirname(__file__)) + return os.path.join(test_dir, "fixtures", relapath) +def fixture(name): + return open(fixture_path(name), 'rb').read() + +def absolute_project_path(): + return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) + def copy_files_globbed(source_glob, target_dir, hard_link_ok=False): """Copy all files found according to the given source glob into the target directory :param hard_link_ok: if True, hard links will be created if possible. Otherwise diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 4fd82899..f365e5b4 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -19,24 +19,11 @@ from base import ( __all__ = ( - 'fixture_path', 'fixture', 'absolute_project_path', 'StringProcessAdapter', + 'StringProcessAdapter', 'GlobalsItemDeletorMetaCls', 'with_rw_repo', 'with_rw_and_rw_remote_repo', 'TestBase', 'TestCase', - 'GlobalsItemDeletorMetaCls' - ) + ) -#{ Routines -def fixture_path(name): - test_dir = os.path.dirname(os.path.dirname(__file__)) - return os.path.join(test_dir, "fixtures", name) - -def fixture(name): - return open(fixture_path(name), 'rb').read() - -def absolute_project_path(): - return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) - -#} END routines #{ Adapters @@ -227,37 +214,10 @@ class GlobalsItemDeletorMetaCls(type): class TestBase(TestCase): """ Base Class providing default functionality to all tests such as: - - Utility functions provided by the TestCase base of the unittest method such as:: self.fail("todo") self.failUnlessRaises(...) - - - Class level repository which is considered read-only as it is shared among - all test cases in your type. - Access it using:: - self.rorepo # 'ro' stands for read-only - - The rorepo is in fact your current project's git repo. If you refer to specific - shas for your objects, be sure you choose some that are part of the immutable portion - of the project history ( to assure tests don't fail for others ). - - Derived types can override the default repository type to create a differnt - read-only repo, allowing to test their specific type """ - #{ Configuration - # The repository type to instantiate. It takes at least a path to operate upon - # during instantiation. - RepoCls = None - #} END configuration - - @classmethod - def setUpAll(cls): - """ - Dynamically add a read-only repository to our actual type. This way - each test type has its own repository - """ - assert cls.RepoCls is not None, "RepoCls class member must be set" - cls.rorepo = cls.RepoCls(rorepo_dir()) def _make_file(self, rela_path, data, repo=None): """ |