@@ -15,21 +15,22 @@ class BoostTestFacade(object):
1515 @classmethod
1616 def is_test_suite (cls , executable ):
1717 try :
18- output = subprocess .check_output ([executable , '--help' ],
19- stderr = subprocess .STDOUT ,
20- universal_newlines = True )
18+ output = subprocess .check_output (
19+ [executable , "--help" ],
20+ stderr = subprocess .STDOUT ,
21+ universal_newlines = True ,
22+ )
2123 except (subprocess .CalledProcessError , OSError ):
2224 return False
2325 else :
24- return ' --output_format' in output and ' log_format' in output
26+ return " --output_format" in output and " log_format" in output
2527
2628 def list_tests (self , executable ):
2729 # unfortunately boost doesn't provide us with a way to list the tests
2830 # inside the executable, so the test_id is a dummy placeholder :(
2931 return [os .path .basename (os .path .splitext (executable )[0 ])]
3032
3133 def run_test (self , executable , test_id , test_args = ()):
32-
3334 def read_file (name ):
3435 try :
3536 with io .open (name ) as f :
@@ -38,13 +39,13 @@ def read_file(name):
3839 return None
3940
4041 temp_dir = tempfile .mkdtemp ()
41- log_xml = os .path .join (temp_dir , ' log.xml' )
42- report_xml = os .path .join (temp_dir , ' report.xml' )
42+ log_xml = os .path .join (temp_dir , " log.xml" )
43+ report_xml = os .path .join (temp_dir , " report.xml" )
4344 args = [
4445 executable ,
45- ' --output_format=XML' ,
46- ' --log_sink=%s' % log_xml ,
47- ' --report_sink=%s' % report_xml ,
46+ " --output_format=XML" ,
47+ " --log_sink=%s" % log_xml ,
48+ " --report_sink=%s" % report_xml ,
4849 ]
4950 args .extend (test_args )
5051 p = subprocess .Popen (args , stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
@@ -54,27 +55,33 @@ def read_file(name):
5455 report = read_file (report_xml )
5556
5657 if p .returncode not in (0 , 200 , 201 ):
57- msg = ('Internal Error: calling {executable} '
58- 'for test {test_id} failed (returncode={returncode}):\n '
59- 'output:{stdout}\n '
60- 'log:{log}\n '
61- 'report:{report}' )
58+ msg = (
59+ "Internal Error: calling {executable} "
60+ "for test {test_id} failed (returncode={returncode}):\n "
61+ "output:{stdout}\n "
62+ "log:{log}\n "
63+ "report:{report}"
64+ )
6265 failure = BoostTestFailure (
63- ' <no source file>' ,
66+ " <no source file>" ,
6467 linenum = 0 ,
65- contents = msg .format (executable = executable ,
66- test_id = test_id ,
67- stdout = stdout ,
68- log = log ,
69- report = report ,
70- returncode = p .returncode ))
68+ contents = msg .format (
69+ executable = executable ,
70+ test_id = test_id ,
71+ stdout = stdout ,
72+ log = log ,
73+ report = report ,
74+ returncode = p .returncode ,
75+ ),
76+ )
7177 return [failure ]
7278
7379 if report is not None and (
74- report .startswith ('Boost.Test framework internal error: ' ) or
75- report .startswith ('Test setup error: ' )):
80+ report .startswith ("Boost.Test framework internal error: " )
81+ or report .startswith ("Test setup error: " )
82+ ):
7683 # boost.test doesn't do XML output on fatal-enough errors.
77- failure = BoostTestFailure (' unknown location' , 0 , report )
84+ failure = BoostTestFailure (" unknown location" , 0 , report )
7885 return [failure ]
7986
8087 results = self ._parse_log (log = log )
@@ -93,22 +100,22 @@ def _parse_log(self, log):
93100 # <FatalError>...</FatalError><TestLog>...</TestLog>
94101 # so we have to manually split it into two xmls if that's the case.
95102 parsed_elements = []
96- if log .startswith (' <FatalError' ):
97- fatal , log = log .split (' </FatalError>' )
98- fatal += ' </FatalError>' # put it back, removed by split()
103+ if log .startswith (" <FatalError" ):
104+ fatal , log = log .split (" </FatalError>" )
105+ fatal += " </FatalError>" # put it back, removed by split()
99106 fatal_root = ElementTree .fromstring (fatal )
100- fatal_root .text = ' Fatal Error: %s' % fatal_root .text
107+ fatal_root .text = " Fatal Error: %s" % fatal_root .text
101108 parsed_elements .append (fatal_root )
102109
103110 log_root = ElementTree .fromstring (log )
104- parsed_elements .extend (log_root .findall (' Exception' ))
105- parsed_elements .extend (log_root .findall (' Error' ))
106- parsed_elements .extend (log_root .findall (' FatalError' ))
111+ parsed_elements .extend (log_root .findall (" Exception" ))
112+ parsed_elements .extend (log_root .findall (" Error" ))
113+ parsed_elements .extend (log_root .findall (" FatalError" ))
107114
108115 result = []
109116 for elem in parsed_elements :
110- filename = elem .attrib [' file' ]
111- linenum = int (elem .attrib [' line' ])
117+ filename = elem .attrib [" file" ]
118+ linenum = int (elem .attrib [" line" ])
112119 result .append (BoostTestFailure (filename , linenum , elem .text ))
113120 return result
114121
@@ -120,7 +127,7 @@ def __init__(self, filename, linenum, contents):
120127 self .lines = contents .splitlines ()
121128
122129 def get_lines (self ):
123- m = (' red' , ' bold' )
130+ m = (" red" , " bold" )
124131 return [(x , m ) for x in self .lines ]
125132
126133 def get_file_reference (self ):
0 commit comments