aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonan Amicel <ronan.amicel@gmail.com>2012-09-12 04:41:04 +0200
committerRonan Amicel <ronan.amicel@gmail.com>2012-09-12 04:41:50 +0200
commitf570bea8509dfb8c58216147656586ea76e79af0 (patch)
tree593ef1f6696b57180c4cfc56c2b8f3a337ee5142
parentFix OpenVZ integration test (diff)
downloadfabtools-f570bea8509dfb8c58216147656586ea76e79af0.tar.xz
Fix vagrant test cases
-rw-r--r--fabtools/tests/test_vagrant.py18
-rw-r--r--fabtools/tests/vagrant.py19
2 files changed, 10 insertions, 27 deletions
diff --git a/fabtools/tests/test_vagrant.py b/fabtools/tests/test_vagrant.py
index 33ccbe7..974b3a5 100644
--- a/fabtools/tests/test_vagrant.py
+++ b/fabtools/tests/test_vagrant.py
@@ -5,24 +5,13 @@ import os.path
from fabric.main import load_fabfile
-def short_doc(obj):
- """
- Returns the first line of the object's docstring
- """
- if obj.__doc__:
- lines = obj.__doc__.strip(' \n').splitlines()
- if lines:
- return lines[0]
- return None
-
-
def load_tests(loader, suite, patterns):
"""
Custom test loader for functional tests
"""
# Try to add vagrant functional tests
- from .vagrant import base_boxes, VagrantFunctionTestCase, VagrantTestSuite
+ from .vagrant import base_boxes, VagrantTestCase, VagrantTestSuite
boxes = base_boxes()
if boxes:
vagrant_suite = VagrantTestSuite(boxes)
@@ -33,9 +22,8 @@ def load_tests(loader, suite, patterns):
if fnmatch.fnmatch(filename, '[!_]*.py'):
fabfile = os.path.join(fabfiles, filename)
_, tasks, _ = load_fabfile(fabfile)
- for task in tasks.values():
- test = VagrantFunctionTestCase(task,
- description=short_doc(task))
+ for name, callable in tasks.iteritems():
+ test = VagrantTestCase(name, callable)
vagrant_suite.addTest(test)
suite.addTest(vagrant_suite)
diff --git a/fabtools/tests/vagrant.py b/fabtools/tests/vagrant.py
index 833ec27..c2fcaf1 100644
--- a/fabtools/tests/vagrant.py
+++ b/fabtools/tests/vagrant.py
@@ -167,6 +167,11 @@ class VagrantTestCase(unittest.TestCase):
Test case with vagrant support
"""
+ def __init__(self, name, callable):
+ super(VagrantTestCase, self).__init__()
+ self._name = name
+ self._callable = callable
+
def run(self, result=None):
"""
Run the test case within a Fabric context manager
@@ -174,15 +179,5 @@ class VagrantTestCase(unittest.TestCase):
with self._suite.settings():
unittest.TestCase.run(self, result)
-
-class VagrantFunctionTestCase(unittest.FunctionTestCase):
- """
- Function test case with vagrant support
- """
-
- def run(self, result=None):
- """
- Run the test case within a Fabric context manager
- """
- with self._suite.settings():
- unittest.FunctionTestCase.run(self, result)
+ def runTest(self):
+ self._callable()