diff options
author | Michał Górny <mgorny@gentoo.org> | 2011-08-11 10:48:35 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2011-08-11 10:48:35 +0200 |
commit | 4f7717a20f5f6cc473be837deeca1fe0a1c9a1be (patch) | |
tree | 52ecd06644a22c2807d0e27f888d6e5c3883c41d | |
parent | Bump PV to 0.0.4. (diff) | |
download | pms-test-suite-4f7717a20f5f6cc473be837deeca1fe0a1c9a1be.tar.gz pms-test-suite-4f7717a20f5f6cc473be837deeca1fe0a1c9a1be.tar.bz2 pms-test-suite-4f7717a20f5f6cc473be837deeca1fe0a1c9a1be.zip |
Store short test names.
-rw-r--r-- | pmstestsuite/library/__init__.py | 6 | ||||
-rw-r--r-- | pmstestsuite/library/case.py | 31 |
2 files changed, 23 insertions, 14 deletions
diff --git a/pmstestsuite/library/__init__.py b/pmstestsuite/library/__init__.py index 473e9b0..3f7554b 100644 --- a/pmstestsuite/library/__init__.py +++ b/pmstestsuite/library/__init__.py @@ -27,13 +27,13 @@ from pmstestsuite.library.case import TestCase class TestLibrary(ABCObject): """ Base class for a test library. - + @ivar tests: cache of instantiated tests @type tests: list(L{TestCase}) """ tests = None - + @abstractproperty def test_names(self): """ @@ -66,7 +66,7 @@ class TestLibrary(ABCObject): mod = __import__(modname, {}, {}, [clsname], 0) cls = getattr(mod, clsname) for i in cls.inst_all(thorough = self.thorough, - undefined = self.undefined): + undefined = self.undefined, short_name = t): self.tests.append(i) yield i diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py index 06d7c2f..76011e9 100644 --- a/pmstestsuite/library/case.py +++ b/pmstestsuite/library/case.py @@ -168,8 +168,22 @@ class TestCase(ABCObject): _finalized = False - def __init__(self): + def __init__(self, short_name): self.assertions = [] + self._short_name = short_name + + @property + def short_name(self): + return self._short_name + + @property + def _stripped_docstring(self): + descdoc = ' '.join(self.__doc__.split()) + return descdoc.rstrip('.') + + def __str__(self): + """ Return freetext test description. """ + return '%s (%s)' % (self.short_name, self._stripped_docstring) def _finalize(self): """ @@ -393,7 +407,7 @@ class EbuildTestCase(TestCase): return (tuple(known_eapis),) @classmethod - def inst_all(cls, thorough = False, undefined = False): + def inst_all(cls, short_name, thorough = False, undefined = False): """ Instantiate the test case, choosing a single EAPI from each EAPI group listed in L{supported_eapis}. If thorough mode is enabled, all EAPIs @@ -421,7 +435,7 @@ class EbuildTestCase(TestCase): eapis = [random.choice(x) for x in supported_eapis] for eapi in eapis: - yield cls(eapi = eapi) + yield cls(eapi = eapi, short_name = short_name) @property def pn(self): @@ -444,11 +458,6 @@ class EbuildTestCase(TestCase): """ Return atom for the test. """ return pm.Atom('=%s' % self.cpv) - @property - def _stripped_docstring(self): - descdoc = ' '.join(self.__doc__.split()) - return descdoc.rstrip('.') - def _finalize(self): TestCase._finalize(self) @@ -457,17 +466,17 @@ class EbuildTestCase(TestCase): def __str__(self): """ Return freetext test description. """ - return '%s:%s (%s)' % (self.__class__.__name__, self.eapi, + return '%s:%s (%s)' % (self.short_name, self.eapi, self._stripped_docstring) - def __init__(self, eapi): + def __init__(self, eapi, short_name): """ Instiantate the test case for a particular EAPI. @param eapi: the EAPI @type eapi: string """ - TestCase.__init__(self) + TestCase.__init__(self, short_name) self.eapi = eapi for v in ('ebuild_vars', 'inherits', 'phase_funcs'): |