summaryrefslogtreecommitdiff
path: root/test/testlib
diff options
context:
space:
mode:
authorMichael Trier <mtrier@gmail.com>2008-05-07 22:37:17 -0400
committerMichael Trier <mtrier@gmail.com>2008-05-07 22:37:17 -0400
commit9066712dca21ef35c534e068f2cc4fefdccf1ea3 (patch)
tree10e04737320fdab63f749bf91260f0d91cec9d36 /test/testlib
parent933d23bf95a5bd1624fbcdf328d904e1fa173474 (diff)
downloadgitpython-9066712dca21ef35c534e068f2cc4fefdccf1ea3.tar.gz
Moved test stuff around and modified imports to just clean things up a bit.
Diffstat (limited to 'test/testlib')
-rw-r--r--test/testlib/__init__.py7
-rw-r--r--test/testlib/asserts.py32
-rw-r--r--test/testlib/helper.py10
3 files changed, 49 insertions, 0 deletions
diff --git a/test/testlib/__init__.py b/test/testlib/__init__.py
new file mode 100644
index 00000000..3662435d
--- /dev/null
+++ b/test/testlib/__init__.py
@@ -0,0 +1,7 @@
+import inspect
+from mock import *
+from asserts import *
+from helper import *
+
+__all__ = [ name for name, obj in locals().items()
+ if not (name.startswith('_') or inspect.ismodule(obj)) ]
diff --git a/test/testlib/asserts.py b/test/testlib/asserts.py
new file mode 100644
index 00000000..33dd843b
--- /dev/null
+++ b/test/testlib/asserts.py
@@ -0,0 +1,32 @@
+import re
+import unittest
+from nose import tools
+from nose.tools import *
+
+__all__ = ['assert_instance_of', 'assert_not_instance_of',
+ 'assert_none', 'assert_not_none',
+ 'assert_match', 'assert_not_match'] + tools.__all__
+
+def assert_instance_of(expected, actual, msg=None):
+ """Verify that object is an instance of expected """
+ assert isinstance(actual, expected), msg
+
+def assert_not_instance_of(expected, actual, msg=None):
+ """Verify that object is not an instance of expected """
+ assert not isinstance(actual, expected, msg)
+
+def assert_none(actual, msg=None):
+ """verify that item is None"""
+ assert_equal(None, actual, msg)
+
+def assert_not_none(actual, msg=None):
+ """verify that item is None"""
+ assert_not_equal(None, actual, msg)
+
+def assert_match(pattern, string, msg=None):
+ """verify that the pattern matches the string"""
+ assert_not_none(re.search(pattern, string), msg)
+
+def assert_not_match(pattern, string, msg=None):
+ """verify that the pattern does not match the string"""
+ assert_none(re.search(pattern, string), msg) \ No newline at end of file
diff --git a/test/testlib/helper.py b/test/testlib/helper.py
new file mode 100644
index 00000000..19cff8f5
--- /dev/null
+++ b/test/testlib/helper.py
@@ -0,0 +1,10 @@
+import os
+
+GIT_REPO = os.path.join(os.path.dirname(__file__), "..", "..")
+
+def fixture(name):
+ file = open(os.path.join(os.path.dirname(__file__), "..", "fixtures", name))
+ return file.read()
+
+def absolute_project_path():
+ return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) \ No newline at end of file