From 9066712dca21ef35c534e068f2cc4fefdccf1ea3 Mon Sep 17 00:00:00 2001 From: Michael Trier Date: Wed, 7 May 2008 22:37:17 -0400 Subject: Moved test stuff around and modified imports to just clean things up a bit. --- test/asserts.py | 32 -------------------------------- test/git/test_actor.py | 3 +-- test/git/test_blob.py | 4 +--- test/git/test_commit.py | 4 +--- test/git/test_diff.py | 3 +-- test/git/test_git.py | 4 +--- test/git/test_head.py | 4 +--- test/git/test_repo.py | 4 +--- test/git/test_stats.py | 3 +-- test/git/test_tag.py | 4 ++-- test/git/test_tree.py | 4 +--- test/git/test_utils.py | 3 +-- test/helper.py | 10 ---------- test/testlib/__init__.py | 7 +++++++ test/testlib/asserts.py | 32 ++++++++++++++++++++++++++++++++ test/testlib/helper.py | 10 ++++++++++ 16 files changed, 61 insertions(+), 70 deletions(-) delete mode 100644 test/asserts.py delete mode 100644 test/helper.py create mode 100644 test/testlib/__init__.py create mode 100644 test/testlib/asserts.py create mode 100644 test/testlib/helper.py (limited to 'test') diff --git a/test/asserts.py b/test/asserts.py deleted file mode 100644 index 33dd843b..00000000 --- a/test/asserts.py +++ /dev/null @@ -1,32 +0,0 @@ -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/git/test_actor.py b/test/git/test_actor.py index 2fc7781f..14b78f19 100644 --- a/test/git/test_actor.py +++ b/test/git/test_actor.py @@ -1,7 +1,6 @@ import os -from test.asserts import * +from test.testlib import * from git_python import * -from test.helper import * class TestActor(object): def test_from_string_should_separate_name_and_email(self): diff --git a/test/git/test_blob.py b/test/git/test_blob.py index f41429a6..1d84e1d8 100644 --- a/test/git/test_blob.py +++ b/test/git/test_blob.py @@ -1,8 +1,6 @@ import time -from mock import * -from test.asserts import * +from test.testlib import * from git_python import * -from test.helper import * class TestBlob(object): def setup(self): diff --git a/test/git/test_commit.py b/test/git/test_commit.py index 825eba5a..65e92812 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -1,7 +1,5 @@ -from mock import * -from test.asserts import * +from test.testlib import * from git_python import * -from test.helper import * class TestCommit(object): def setup(self): diff --git a/test/git/test_diff.py b/test/git/test_diff.py index c9352a18..b605eddd 100644 --- a/test/git/test_diff.py +++ b/test/git/test_diff.py @@ -1,6 +1,5 @@ -from test.asserts import * +from test.testlib import * from git_python import * -from test.helper import * class TestDiff(object): def setup(self): diff --git a/test/git/test_git.py b/test/git/test_git.py index 973f242a..0634a5dd 100644 --- a/test/git/test_git.py +++ b/test/git/test_git.py @@ -1,8 +1,6 @@ import os -from mock import * -from test.asserts import * +from test.testlib import * from git_python import * -from test.helper import * class TestGit(object): def setup(self): diff --git a/test/git/test_head.py b/test/git/test_head.py index fff3c0a0..47cfb608 100644 --- a/test/git/test_head.py +++ b/test/git/test_head.py @@ -1,7 +1,5 @@ -from mock import * -from test.asserts import * +from test.testlib import * from git_python import * -from test.helper import * class TestHead(object): def setup(self): diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 09238c66..af567811 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -1,9 +1,7 @@ import os import time -from mock import * -from test.asserts import * +from test.testlib import * from git_python import * -from test.helper import * class TestRepo(object): def setup(self): diff --git a/test/git/test_stats.py b/test/git/test_stats.py index 36e35e40..4926ac4f 100644 --- a/test/git/test_stats.py +++ b/test/git/test_stats.py @@ -1,6 +1,5 @@ -from test.asserts import * +from test.testlib import * from git_python import * -from test.helper import * class TestStats(object): def setup(self): diff --git a/test/git/test_tag.py b/test/git/test_tag.py index 14a0990d..fb9613c8 100644 --- a/test/git/test_tag.py +++ b/test/git/test_tag.py @@ -1,7 +1,7 @@ from mock import * -from test.asserts import * -from git_python import * +from test.testlib import * from test.helper import * +from git_python import * class TestTag(object): def setup(self): diff --git a/test/git/test_tree.py b/test/git/test_tree.py index 3739a704..5d8dea67 100644 --- a/test/git/test_tree.py +++ b/test/git/test_tree.py @@ -1,7 +1,5 @@ -from mock import * -from test.asserts import * +from test.testlib import * from git_python import * -from test.helper import * class TestTree(object): def setup(self): diff --git a/test/git/test_utils.py b/test/git/test_utils.py index e3b23b2a..a9af2040 100644 --- a/test/git/test_utils.py +++ b/test/git/test_utils.py @@ -1,7 +1,6 @@ import os -from test.asserts import * +from test.testlib import * from git_python import * -from test.helper import * class TestUtils(object): def setup(self): diff --git a/test/helper.py b/test/helper.py deleted file mode 100644 index 082e57e5..00000000 --- a/test/helper.py +++ /dev/null @@ -1,10 +0,0 @@ -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 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 -- cgit v1.2.1