← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~smoser/cloud-init:fix/citest-show-class-in-failures into cloud-init:master

 

Scott Moser has proposed merging ~smoser/cloud-init:fix/citest-show-class-in-failures into cloud-init:master.

Commit message:
citest: show the class actual class name in results.

Tests are currently run by creating a temporary subclass of each class
and then executing it (in get_suites).  When running the tests suite
the output would contain the temporary class name.  That was less than
useful, and made batch runs almost impossible to identify which
test case had an error.

This change goes from output of:
    FAIL: test_no_warnings_in_log \
        (tests.cloud_tests.testcases.get_suite.<locals>.tmp)
To
    FAIL: test_no_warnings_in_log \
       (tests.cloud_tests.testcases.modules.ntp.TestNtp)

Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/332585
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~smoser/cloud-init:fix/citest-show-class-in-failures into cloud-init:master.
diff --git a/tests/cloud_tests/testcases/__init__.py b/tests/cloud_tests/testcases/__init__.py
index 47217ce..0295082 100644
--- a/tests/cloud_tests/testcases/__init__.py
+++ b/tests/cloud_tests/testcases/__init__.py
@@ -5,6 +5,7 @@
 import importlib
 import inspect
 import unittest
+from unittest.util import strclass
 
 from tests.cloud_tests import config
 from tests.cloud_tests.testcases.base import CloudTestCase as base_test
@@ -37,6 +38,12 @@ def get_suite(test_name, data, conf):
 
         class tmp(test_class):
 
+            _realclass = test_class
+
+            def __str__(self):
+                 return "%s (%s)" % (self._testMethodName,
+                                     strclass(self._realclass))
+
             @classmethod
             def setUpClass(cls):
                 cls.data = data
diff --git a/tests/cloud_tests/testcases/base.py b/tests/cloud_tests/testcases/base.py
index b2b5b4b..d3586e3 100644
--- a/tests/cloud_tests/testcases/base.py
+++ b/tests/cloud_tests/testcases/base.py
@@ -16,10 +16,6 @@ class CloudTestCase(unittest.TestCase):
     conf = None
     _cloud_config = None
 
-    def shortDescription(self):
-        """Prevent nose from using docstrings."""
-        return None
-
     @property
     def cloud_config(self):
         """Get the cloud-config used by the test."""

References