@@ -6,64 +6,61 @@ Prints output as a subunit test suite. If anything goes to stderr, that is
66treated as a test error. If a Python is not available, then it is skipped.
77"""
88
9- from datetime import datetime
109import io
1110import os
1211import subprocess
1312import sys
13+ from datetime import datetime
1414
1515import subunit
1616from subunit import (
17- iso8601 ,
18- _make_stream_binary ,
1917 TestProtocolClient ,
2018 TestProtocolServer ,
21- )
19+ _make_stream_binary ,
20+ iso8601 ,
21+ )
22+
2223from testtools import (
2324 PlaceHolder ,
24- TestCase ,
25- )
25+ )
2626from testtools .content import text_content
2727
28-
2928ROOT = os .path .dirname (os .path .dirname (__file__ ))
3029
3130
3231def run_for_python (version , result , tests ):
3332 if not tests :
34- tests = [' tests.test_suite' ]
33+ tests = [" tests.test_suite" ]
3534 # XXX: This could probably be broken up and put into subunit.
36- python = ' python%s' % ( version ,)
35+ python = f" python{ version } "
3736 # XXX: Correct API, but subunit doesn't support it. :(
3837 # result.tags(set(python), set())
3938 result .time (now ())
40- test = PlaceHolder ('' .join (c for c in python if c != '.' ))
39+ test = PlaceHolder ("" .join (c for c in python if c != "." ))
4140 process = subprocess .Popen (
42- '%s -c pass' % ( python ,), shell = True ,
43- stdout = subprocess . PIPE , stderr = subprocess . PIPE )
41+ f" { python } -c pass" , shell = True , stdout = subprocess . PIPE , stderr = subprocess . PIPE
42+ )
4443 process .communicate ()
4544
4645 if process .returncode :
4746 result .startTest (test )
48- result .addSkip (test , reason = '%s not available' % ( python ,) )
47+ result .addSkip (test , reason = f" { python } not available" )
4948 result .stopTest (test )
5049 return
5150
5251 env = os .environ .copy ()
53- if env .get (' PYTHONPATH' , None ):
54- env [' PYTHONPATH' ] = os .pathsep .join ([ROOT , env [' PYTHONPATH' ]])
52+ if env .get (" PYTHONPATH" , None ):
53+ env [" PYTHONPATH" ] = os .pathsep .join ([ROOT , env [" PYTHONPATH" ]])
5554 else :
56- env [' PYTHONPATH' ] = ROOT
55+ env [" PYTHONPATH" ] = ROOT
5756 result .time (now ())
5857 protocol = TestProtocolServer (result )
59- subunit_path = os .path .join (os .path .dirname (subunit .__file__ ), 'run.py' )
60- cmd = [
61- python ,
62- '-W' , 'ignore:Module testtools was already imported' ,
63- subunit_path ]
58+ subunit_path = os .path .join (os .path .dirname (subunit .__file__ ), "run.py" )
59+ cmd = [python , "-W" , "ignore:Module testtools was already imported" , subunit_path ]
6460 cmd .extend (tests )
6561 process = subprocess .Popen (
66- cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE , env = env )
62+ cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE , env = env
63+ )
6764 _make_stream_binary (process .stdout )
6865 _make_stream_binary (process .stderr )
6966 # XXX: This buffers everything. Bad for memory, bad for getting progress
@@ -72,22 +69,24 @@ def run_for_python(version, result, tests):
7269 protocol .readFrom (io .BytesIO (output ))
7370 if error :
7471 result .startTest (test )
75- result .addError (test , details = {
76- 'stderr' : text_content (error ),
77- })
72+ result .addError (
73+ test ,
74+ details = {
75+ "stderr" : text_content (error ),
76+ },
77+ )
7878 result .stopTest (test )
7979 result .time (now ())
8080 # XXX: Correct API, but subunit doesn't support it. :(
81- #result.tags(set(), set(python))
81+ # result.tags(set(), set(python))
8282
8383
8484def now ():
8585 return datetime .now (tz = iso8601 .Utc ())
8686
8787
88-
89- if __name__ == '__main__' :
88+ if __name__ == "__main__" :
9089 sys .path .append (ROOT )
9190 result = TestProtocolClient (sys .stdout )
92- for version in ' 3.10 3.11 3.12 3.13 3.14' .split ():
91+ for version in " 3.10 3.11 3.12 3.13 3.14" .split ():
9392 run_for_python (version , result , sys .argv [1 :])
0 commit comments