11# Python Tools for Visual Studio
22# Copyright(c) Microsoft Corporation
33# All rights reserved.
4- < << << << a3034a0dafa547afd949f2b0dcbdcba6accb5764
54#
65# Licensed under the Apache License, Version 2.0 (the License); you may not use
76# this file except in compliance with the License. You may obtain a copy of the
87# License at http://www.apache.org/licenses/LICENSE-2.0
98#
10- == == == =
11- #
12- # Licensed under the Apache License, Version 2.0 (the License); you may not use
13- # this file except in compliance with the License. You may obtain a copy of the
14- # License at http://www.apache.org/licenses/LICENSE-2.0
15- #
16- >> >> >> > unitests using python unittest framework #239
179# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
1810# OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
1911# IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
2012# MERCHANTABLITY OR NON-INFRINGEMENT.
21- < << << << a3034a0dafa547afd949f2b0dcbdcba6accb5764
2213#
23- == == == =
24- #
25- >> >> >> > unitests using python unittest framework #239
2614# See the Apache Version 2.0 License for specific language governing
2715# permissions and limitations under the License.
2816
@@ -55,19 +43,11 @@ def __init__(self, old_out, is_stdout):
5543 def flush (self ):
5644 if self .old_out :
5745 self .old_out .flush ()
58- < << << << a3034a0dafa547afd949f2b0dcbdcba6accb5764
5946
6047 def writelines (self , lines ):
6148 for line in lines :
6249 self .write (line )
6350
64- == == == =
65-
66- def writelines (self , lines ):
67- for line in lines :
68- self .write (line )
69-
70- >> >> >> > unitests using python unittest framework #239
7151 @property
7252 def encoding (self ):
7353 return 'utf8'
@@ -76,23 +56,15 @@ def write(self, value):
7656 _channel .send_event ('stdout' if self .is_stdout else 'stderr' , content = value )
7757 if self .old_out :
7858 self .old_out .write (value )
79- < << << << a3034a0dafa547afd949f2b0dcbdcba6accb5764
8059 # flush immediately, else things go wonky and out of order
8160 self .flush ()
8261
83- == == == =
84-
85- >> >> >> > unitests using python unittest framework #239
8662 def isatty (self ):
8763 return True
8864
8965 def next (self ):
9066 pass
91- < << << << a3034a0dafa547afd949f2b0dcbdcba6accb5764
9267
93- == == == =
94-
95- >> >> >> > unitests using python unittest framework #239
9668 @property
9769 def name (self ):
9870 if self .is_stdout :
@@ -112,11 +84,7 @@ def write(self, data):
11284 _channel .send_event ('stdout' if self .is_stdout else 'stderr' , content = data )
11385 self .buffer .write (data )
11486
115- < << << << a3034a0dafa547afd949f2b0dcbdcba6accb5764
11687 def flush (self ):
117- == == == =
118- def flush (self ):
119- >> >> >> > unitests using python unittest framework #239
12088 self .buffer .flush ()
12189
12290 def truncate (self , pos = None ):
@@ -161,21 +129,13 @@ def startTest(self, test):
161129 super (VsTestResult , self ).startTest (test )
162130 if _channel is not None :
163131 _channel .send_event (
164- << << << < a3034a0dafa547afd949f2b0dcbdcba6accb5764
165132 name = 'start' ,
166- == == == =
167- name = 'start' ,
168- >> >> >> > unitests using python unittest framework #239
169133 test = test .id ()
170134 )
171135
172136 def addError (self , test , err ):
173137 super (VsTestResult , self ).addError (test , err )
174- << << << < a3034a0dafa547afd949f2b0dcbdcba6accb5764
175138 self .sendResult (test , 'error' , err )
176- == == == =
177- self .sendResult (test , 'failed' , err )
178- >> >> >> > unitests using python unittest framework #239
179139
180140 def addFailure (self , test , err ):
181141 super (VsTestResult , self ).addFailure (test , err )
@@ -209,11 +169,7 @@ def sendResult(self, test, outcome, trace = None):
209169 tb = '' .join (formatted )
210170 message = str (trace [1 ])
211171 _channel .send_event (
212- << << << < a3034a0dafa547afd949f2b0dcbdcba6accb5764
213172 name = 'result' ,
214- == == == =
215- name = 'result' ,
216- >> >> >> > unitests using python unittest framework #239
217173 outcome = outcome ,
218174 traceback = tb ,
219175 message = message ,
@@ -226,11 +182,7 @@ def stopTests():
226182class ExitCommand (Exception ):
227183 pass
228184
229- < << << << a3034a0dafa547afd949f2b0dcbdcba6accb5764
230185def signal_handler (signal , frame ):
231- == == == =
232- def signal_handler (signal , frame ):
233- > >> >> >> unitests using python unittest framework #239
234186 raise ExitCommand ()
235187
236188def main ():
@@ -250,19 +202,11 @@ def main():
250202 parser .add_option ('--us' , type = 'str' , help = 'Directory to start discovery' )
251203 parser .add_option ('--up' , type = 'str' , help = 'Pattern to match test files (' 'test*.py' ' default)' )
252204 parser .add_option ('--ut' , type = 'str' , help = 'Top level directory of project (default to start directory)' )
253- < << << << a3034a0dafa547afd949f2b0dcbdcba6accb5764
254205 parser .add_option ('--uvInt' , '--verboseInt' , type = 'int' , help = 'Verbose output (0 none, 1 (no -v) simple, 2 (-v) full)' )
255206 parser .add_option ('--uf' , '--failfast' , type = 'str' , help = 'Stop on first failure' )
256207 parser .add_option ('--uc' , '--catch' , type = 'str' , help = 'Catch control-C and display results' )
257208 (opts , _ ) = parser .parse_args ()
258209
259- == == == =
260- parser .add_option ('--uvInt' , '--verboseInt' , type = 'int' , help = 'Verbose output' )
261- parser .add_option ('--uf' , '--failfast' , type = 'str' , help = 'Stop on first failure' )
262- parser .add_option ('--uc' , '--catch' , type = 'str' , help = 'Catch control-C and display results' )
263- (opts , _ ) = parser .parse_args ()
264-
265- >> >> >> > unitests using python unittest framework #239
266210 sys .path [0 ] = os .getcwd ()
267211 if opts .result_port :
268212 signal .signal (signal .SIGUSR1 , signal_handler )
@@ -280,11 +224,7 @@ def main():
280224 enable_attach (opts .secret , ('127.0.0.1' , getattr (opts , 'port' , DEFAULT_PORT )), redirect_output = True )
281225 wait_for_attach ()
282226 elif opts .mixed_mode :
283- < << << << a3034a0dafa547afd949f2b0dcbdcba6accb5764
284227 # For mixed-mode attach, there's no ptvsd and hence no wait_for_attach(),
285- == == == =
286- # For mixed-mode attach, there's no ptvsd and hence no wait_for_attach(),
287- >> >> >> > unitests using python unittest framework #239
288228 # so we have to use Win32 API in a loop to do the same thing.
289229 from time import sleep
290230 from ctypes import windll , c_char
@@ -325,14 +265,8 @@ def main():
325265 runner = unittest .TextTestRunner (verbosity = opts .uvInt , resultclass = VsTestResult )
326266 if opts .uf is not None :
327267 runner .failfast = 1
328- << << << < a3034a0dafa547afd949f2b0dcbdcba6accb5764
329268
330269 result = runner .run (tests )
331- == == == =
332-
333- result = runner .run (tests )
334-
335- >> >> >> > unitests using python unittest framework #239
336270 sys .exit (not result .wasSuccessful ())
337271 finally :
338272 if cov is not None :
@@ -344,7 +278,6 @@ def main():
344278 name = 'done'
345279 )
346280 _channel .socket .close ()
347- < << << << a3034a0dafa547afd949f2b0dcbdcba6accb5764
348281 # prevent generation of the error 'Error in sys.exitfunc:'
349282 try :
350283 sys .stdout .close ()
@@ -354,8 +287,6 @@ def main():
354287 sys .stderr .close ()
355288 except :
356289 pass
357- == == == =
358- >> >> >> > unitests using python unittest framework #239
359290
360291if __name__ == '__main__' :
361292 main ()
0 commit comments