88
99DEFAULT_CONDITION_POLL_TIME = 17
1010DEFAULT_CONDITION_TIMEOUT = 4000
11- AWAIT_WORKER = ' AWAIT_WORKER'
11+ AWAIT_WORKER = " AWAIT_WORKER"
1212# Extract `set_timeout_async`, t.i. *avoid* late binding, in case a user
1313# patches it
1414run_on_worker = sublime .set_timeout_async
@@ -34,7 +34,8 @@ def __init__(
3434 condition_timeout = DEFAULT_CONDITION_TIMEOUT ,
3535 ):
3636 super (DeferringTextTestRunner , self ).__init__ (
37- stream , descriptions , verbosity , failfast , buffer , resultclass , warnings )
37+ stream , descriptions , verbosity , failfast , buffer , resultclass , warnings
38+ )
3839 self .condition_timeout = condition_timeout
3940
4041 def run (self , test ):
@@ -56,13 +57,13 @@ def _start_testing():
5657 # no more than once per module, because they can be fairly
5758 # noisy. The -Wd and -Wa flags can be used to bypass this
5859 # only when self.warnings is None.
59- if self .warnings in [' default' , ' always' ]:
60+ if self .warnings in [" default" , " always" ]:
6061 warnings .filterwarnings (
61- ' module' ,
62+ " module" ,
6263 category = DeprecationWarning ,
63- message = ' Please use assert\\ w+ instead.'
64+ message = " Please use assert\\ w+ instead." ,
6465 )
65- startTestRun = getattr (result , ' startTestRun' , None )
66+ startTestRun = getattr (result , " startTestRun" , None )
6667 if startTestRun is not None :
6768 startTestRun ()
6869 try :
@@ -81,8 +82,11 @@ def _continue_testing(deferred, send_value=None, throw_value=None):
8182
8283 if callable (condition ):
8384 defer (0 , _wait_condition , deferred , condition )
84- elif isinstance (condition , dict ) and "condition" in condition and \
85- callable (condition ["condition" ]):
85+ elif (
86+ isinstance (condition , dict )
87+ and "condition" in condition
88+ and callable (condition ["condition" ])
89+ ):
8690 period = condition .get ("period" , DEFAULT_CONDITION_POLL_TIME )
8791 defer (period , _wait_condition , deferred , ** condition )
8892 elif isinstance (condition , int ):
@@ -103,7 +107,7 @@ def _wait_condition(
103107 condition ,
104108 period = DEFAULT_CONDITION_POLL_TIME ,
105109 timeout = self .condition_timeout ,
106- start_time = None
110+ start_time = None ,
107111 ):
108112 if start_time is None :
109113 start_time = time .time ()
@@ -118,41 +122,56 @@ def _wait_condition(
118122 _continue_testing (deferred , send_value = send_value )
119123 elif (time .time () - start_time ) * 1000 >= timeout :
120124 error = TimeoutError (
121- 'Condition not fulfilled within {:.2f} seconds'
122- .format (timeout / 1000 )
125+ "Condition not fulfilled within {:.2f} seconds" .format (
126+ timeout / 1000
127+ )
123128 )
124129 _continue_testing (deferred , throw_value = error )
125130 else :
126- defer (period , _wait_condition , deferred , condition , period , timeout , start_time )
131+ defer (
132+ period ,
133+ _wait_condition ,
134+ deferred ,
135+ condition ,
136+ period ,
137+ timeout ,
138+ start_time ,
139+ )
127140
128141 def _handle_error (e ):
129- stopTestRun = getattr (result , ' stopTestRun' , None )
142+ stopTestRun = getattr (result , " stopTestRun" , None )
130143 if stopTestRun is not None :
131144 stopTestRun ()
132145 self .finished = True
133146 raise e
134147
135148 def _stop_testing ():
136149 with warnings .catch_warnings ():
137- stopTestRun = getattr (result , ' stopTestRun' , None )
150+ stopTestRun = getattr (result , " stopTestRun" , None )
138151 if stopTestRun is not None :
139152 stopTestRun ()
140153
141154 stopTime = time .time ()
142155 timeTaken = stopTime - startTime
143156 result .printErrors ()
144- if hasattr (result , ' separator2' ):
157+ if hasattr (result , " separator2" ):
145158 self .stream .writeln (result .separator2 )
146159 run = result .testsRun
147- self .stream .writeln ("Ran %d test%s in %.3fs" %
148- (run , run != 1 and "s" or "" , timeTaken ))
160+ self .stream .writeln (
161+ "Ran %d test%s in %.3fs" % (run , run != 1 and "s" or "" , timeTaken )
162+ )
149163 self .stream .writeln ()
150164
151165 expectedFails = unexpectedSuccesses = skipped = 0
152166 try :
153- results = map (len , (result .expectedFailures ,
154- result .unexpectedSuccesses ,
155- result .skipped ))
167+ results = map (
168+ len ,
169+ (
170+ result .expectedFailures ,
171+ result .unexpectedSuccesses ,
172+ result .skipped ,
173+ ),
174+ )
156175 except AttributeError :
157176 pass
158177 else :
0 commit comments