--- a/tests/pyscovery_test.py Sun May 26 05:19:56 2013 -0500
+++ b/tests/pyscovery_test.py Sun May 26 05:37:31 2013 -0500
@@ -43,25 +43,25 @@
pyscovery.add_module(module)
gen = pyscovery.find(Plugin, recurse, instantiate)
test.assertTrue(inspect.isgenerator(gen))
test.assertEqual(len(found), count, 'plugins found: {}'.format(len(found)))
test.assertIsInstance(plugin, Plugin)
def _test_module_count(test, count):
Asserts if the number of paths doesn't match count
modules = pyscovery.get_modules()
test.assertEqual(len(modules), count, 'search paths {}'.format(modules))
@@ -76,7 +76,7 @@
def setUp(self): # pylint:disable-msg=C0103
pyscovery.clear_modules()
def tearDown(self): # pylint:disable-msg=C0103
_test_module_count(self, 0)
@@ -91,7 +91,7 @@
pyscovery.add_module(TestModules.module)
_test_module_count(self, 1)
pyscovery.remove_module(TestModules.module)
def test_add_existing(self):
@@ -101,10 +101,10 @@
pyscovery.add_module(TestModules.module)
pyscovery.add_module(TestModules.module)
_test_module_count(self, 1)
pyscovery.remove_module(TestModules.module)
def test_remove_nonexistant(self): # pylint:disable-msg=R0201
Try to remove a non-existant plugin path
@@ -117,15 +117,15 @@
Add multiple paths to the search paths
second = '{}.1'.format(TestModules.module)
pyscovery.add_module(TestModules.module)
_test_module_count(self, 1)
pyscovery.add_module(second)
_test_module_count(self, 2)
pyscovery.remove_module(TestModules.module)
pyscovery.remove_module(second)
@@ -134,51 +134,51 @@
Basic tests for the find function
Test that a TypeError is raised when find is called with None
self.assertRaises(TypeError, pyscovery.find(None, False, False))
Test that a TypeError is raised when find is called with a string
self.assertRaises(TypeError, pyscovery.find('', False, False))
Test that a TypeError is raised when find is called with an int
self.assertRaises(TypeError, pyscovery.find(0, False, False))
def test_old_style_class(self): # pylint:disable-msg=R0201
Test that a TypeError is NOT raised when find is called with an old
class Test: # pylint:disable-msg=R0903,W0232
pyscovery.find(Test, False, False)
def test_new_style_class(self): # pylint:disable-msg=R0201
Test that a TypeError is NOT raised when find is called with an new
class Test(object): # pylint:disable-msg=R0903
@@ -202,17 +202,17 @@
""" Test a module with a single plugin """
_test_module(self, 'tests.modules.single', 1)
""" Test a module with multiple plugins """
_test_module(self, 'tests.modules.multiple', 2)
""" Test a module with more than just plugins """
_test_module(self, 'tests.modules.mixed', 2)
class TestPackage(unittest.TestCase): # pylint:disable-msg=R0904
""" Tests the find method of pyscovery on a package """
@@ -220,17 +220,17 @@
def setUp(self): # pylint:disable-msg=C0103
pyscovery.clear_modules()
def tearDown(self): # pylint:disable-msg=C0103
pyscovery.clear_modules()
def test_package_without_recurse(self):
""" Test a package without recursion """
_test_module(self, 'tests.modules', 0)
def test_package_recursion(self):
""" Test a package with recursion """
_test_module(self, 'tests.modules.deep', 2, recurse=True)
@@ -239,30 +239,30 @@
def test_package_deep_recursion(self):
""" Test a package with recursion """
_test_module(self, 'tests.modules', 7, recurse=True)
class TestCreate(unittest.TestCase): # pylint:disable-msg=R0904
""" Tests the find method with the create option on """
def setUp(self): # pylint:disable-msg=C0103
pyscovery.clear_modules()
def test_create_without_recurse(self):
""" Test a package with create but without recursion """
_test_module(self, 'tests.modules.deep', 1, instantiate=True)
def test_create_with_recursion(self):
""" Test a package with create and recursion """
_test_module(self, 'tests.modules.deep', 2, recurse=True,
def test_create_with_deep_recursion(self):
""" Test a packge with create and deep recursion """
_test_module(self, 'tests.modules', 7, recurse=True, instantiate=True)
class TestCreateWithParameters(unittest.TestCase): # pylint:disable-msg=R0904
""" Tests for finding and creating plugins that take arguments """
@@ -270,26 +270,26 @@
def setUp(self): # pylint:disable-msg=C0103
pyscovery.clear_modules()
pyscovery.add_module('tests.modules.create')
def test_create_args(self):
""" Tests that create works with args """
for plugin in pyscovery.find(create.ArgsPlugin, False, True,
self.assertTupleEqual(plugin.args, ('one', 'two'))
def test_create_kwargs(self):
""" Tests that create works with kwargs """
for plugin in pyscovery.find(create.KwArgsPlugin, False, True,
self.assertDictEqual(plugin.kwargs, {'one': 1, 'two': 2})
def test_both_args(self):
""" Tests the create works with args and kwargs """
for plugin in pyscovery.find(create.BothArgsPlugin, False, True,
'one', 'two', one=1, two=2):
self.assertTupleEqual(plugin.args, ('one', 'two'))