summaryrefslogtreecommitdiff
path: root/test/performance/lib.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-11-21 21:47:18 +0100
committerSebastian Thiel <byronimo@gmail.com>2010-11-21 22:00:45 +0100
commit48a17c87c15b2fa7ce2e84afa09484f354d57a39 (patch)
tree8664414605c3b8f5176c144c18e5f4b9d0715852 /test/performance/lib.py
parent0b813371f5a8af95152cae109d28c7c97bfaf79f (diff)
parent6befb28efd86556e45bb0b213bcfbfa866cac379 (diff)
downloadgitpython-48a17c87c15b2fa7ce2e84afa09484f354d57a39.tar.gz
-#######->WARNING<-####### Directory structure changed, see commit message
If you use git-python as a submodule of your own project, which alters the sys.path to import it, you will have to adjust your code to take the changed directory structure into consideration. Previously, you would put the path ./git-python/lib into your syspath. All modules moved two levels up, which means that the 'git-python' directory now is a package itself. This implies that the submodule's path must change so that the root directory is called 'git'. Your code must now put the directory containing the submodule into the sys.path. For example, if you previously would have the following configuration: ./ext/git-python/lib/git/__init__.py you would now change your submodule path to the following: ./ext/git On the latets revision, the directory structure is changed so that the git/__init__.py file is at the following path: ./ext/git/__init__.py To be able to import git, you need to put ./ext into your sys.path.
Diffstat (limited to 'test/performance/lib.py')
-rw-r--r--test/performance/lib.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/performance/lib.py b/test/performance/lib.py
new file mode 100644
index 00000000..d0727b60
--- /dev/null
+++ b/test/performance/lib.py
@@ -0,0 +1,78 @@
+"""Contains library functions"""
+import os
+from git.test.lib import *
+import shutil
+import tempfile
+
+from git.db import (
+ GitCmdObjectDB,
+ GitDB
+ )
+
+from git import (
+ Repo
+ )
+
+#{ Invvariants
+k_env_git_repo = "GIT_PYTHON_TEST_GIT_REPO_BASE"
+#} END invariants
+
+
+#{ Utilities
+def resolve_or_fail(env_var):
+ """:return: resolved environment variable or raise EnvironmentError"""
+ try:
+ return os.environ[env_var]
+ except KeyError:
+ raise EnvironmentError("Please set the %r envrionment variable and retry" % env_var)
+ # END exception handling
+
+#} END utilities
+
+
+#{ Base Classes
+
+class TestBigRepoR(TestBase):
+ """TestCase providing access to readonly 'big' repositories using the following
+ member variables:
+
+ * gitrorepo
+
+ * Read-Only git repository - actually the repo of git itself
+
+ * puregitrorepo
+
+ * As gitrepo, but uses pure python implementation
+ """
+
+ #{ Invariants
+ head_sha_2k = '235d521da60e4699e5bd59ac658b5b48bd76ddca'
+ head_sha_50 = '32347c375250fd470973a5d76185cac718955fd5'
+ #} END invariants
+
+ @classmethod
+ def setUpAll(cls):
+ super(TestBigRepoR, cls).setUpAll()
+ repo_path = resolve_or_fail(k_env_git_repo)
+ cls.gitrorepo = Repo(repo_path, odbt=GitCmdObjectDB)
+ cls.puregitrorepo = Repo(repo_path, odbt=GitDB)
+
+
+class TestBigRepoRW(TestBigRepoR):
+ """As above, but provides a big repository that we can write to.
+
+ Provides ``self.gitrwrepo`` and ``self.puregitrwrepo``"""
+
+ @classmethod
+ def setUpAll(cls):
+ super(TestBigRepoRW, cls).setUpAll()
+ dirname = tempfile.mktemp()
+ os.mkdir(dirname)
+ cls.gitrwrepo = cls.gitrorepo.clone(dirname, shared=True, bare=True, odbt=GitCmdObjectDB)
+ cls.puregitrwrepo = Repo(dirname, odbt=GitDB)
+
+ @classmethod
+ def tearDownAll(cls):
+ shutil.rmtree(cls.gitrwrepo.working_dir)
+
+#} END base classes