qubes/tests: enhance test runner report
This commit is contained in:
parent
adb144acfe
commit
a686e810b9
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
import curses
|
import curses
|
||||||
import importlib
|
import importlib
|
||||||
|
import socket
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
@ -37,6 +38,8 @@ test_order = [
|
|||||||
|
|
||||||
sys.path.insert(1, '../../')
|
sys.path.insert(1, '../../')
|
||||||
|
|
||||||
|
import qubes.tests
|
||||||
|
|
||||||
class ANSIColor(dict):
|
class ANSIColor(dict):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(ANSIColor, self).__init__()
|
super(ANSIColor, self).__init__()
|
||||||
@ -80,6 +83,7 @@ class ANSITestResult(unittest.TestResult):
|
|||||||
self.descriptions = descriptions
|
self.descriptions = descriptions
|
||||||
|
|
||||||
self.color = ANSIColor()
|
self.color = ANSIColor()
|
||||||
|
self.hostname = socket.gethostname()
|
||||||
|
|
||||||
def _fmtexc(self, err):
|
def _fmtexc(self, err):
|
||||||
if str(err[1]):
|
if str(err[1]):
|
||||||
@ -91,8 +95,11 @@ class ANSITestResult(unittest.TestResult):
|
|||||||
|
|
||||||
def getDescription(self, test): # pylint: disable=invalid-name
|
def getDescription(self, test): # pylint: disable=invalid-name
|
||||||
teststr = str(test).split('/')
|
teststr = str(test).split('/')
|
||||||
teststr[-1] = '{color[bold]}{}{color[normal]}'.format(
|
for i in range(-2, 0):
|
||||||
teststr[-1], color=self.color)
|
fullname = teststr[i].split('_', 2)
|
||||||
|
fullname[-1] = '{color[bold]}{}{color[normal]}'.format(
|
||||||
|
fullname[-1], color=self.color)
|
||||||
|
teststr[i] = '_'.join(fullname)
|
||||||
teststr = '/'.join(teststr)
|
teststr = '/'.join(teststr)
|
||||||
|
|
||||||
doc_first_line = test.shortDescription()
|
doc_first_line = test.shortDescription()
|
||||||
@ -105,6 +112,8 @@ class ANSITestResult(unittest.TestResult):
|
|||||||
def startTest(self, test): # pylint: disable=invalid-name
|
def startTest(self, test): # pylint: disable=invalid-name
|
||||||
super(ANSITestResult, self).startTest(test)
|
super(ANSITestResult, self).startTest(test)
|
||||||
if self.showAll:
|
if self.showAll:
|
||||||
|
if not qubes.tests.in_git:
|
||||||
|
self.stream.write('{}: '.format(self.hostname))
|
||||||
self.stream.write(self.getDescription(test))
|
self.stream.write(self.getDescription(test))
|
||||||
self.stream.write(' ... ')
|
self.stream.write(' ... ')
|
||||||
self.stream.flush()
|
self.stream.flush()
|
||||||
@ -194,7 +203,6 @@ class ANSITestResult(unittest.TestResult):
|
|||||||
|
|
||||||
|
|
||||||
def demo(verbosity=2):
|
def demo(verbosity=2):
|
||||||
import qubes.tests
|
|
||||||
class TC_00_Demo(qubes.tests.QubesTestCase):
|
class TC_00_Demo(qubes.tests.QubesTestCase):
|
||||||
'''Demo class'''
|
'''Demo class'''
|
||||||
# pylint: disable=no-self-use
|
# pylint: disable=no-self-use
|
||||||
|
Loading…
Reference in New Issue
Block a user