blob: 26625e79ff8cc5ed377299d46564b94248c74fd9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/usr/bin/python3-dbg
# -*- coding: utf-8 -*-
import unittest
import os
import sys
class ChrysalideTestCase(unittest.TestCase):
"""Base class for all Chrysalide test cases."""
@classmethod
def setUpClass(cls):
fullname = sys.modules[ChrysalideTestCase.__module__].__file__
filename = os.path.basename(fullname)
cls._baselen = len(fullname) - len(filename)
def shortDescription(self):
"""Discard the direct use of __doc__ strings."""
return None
def __str__(self):
"""Display the description of the current tested case."""
fullname = sys.modules[self.__class__.__module__].__file__
origin = fullname[self._baselen:]
title = self._testMethodDoc and self._testMethodDoc or self._testMethodName
return '[%s] "%s"' % (origin, title)
@classmethod
def log(cls, msg):
"""Display an information message."""
fullname = sys.modules[cls.__module__].__file__
origin = fullname[cls._baselen:]
print('[%s] *** %s ***' % (origin, msg))
|