Skip to content

Commit a9df1f1

Browse files
committed
unitests using python unittest framework #239
1 parent a3034a0 commit a9df1f1

3 files changed

Lines changed: 192 additions & 0 deletions

File tree

pythonFiles/PythonTools/visualstudio_py_testlauncher.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
# Python Tools for Visual Studio
22
# Copyright(c) Microsoft Corporation
33
# All rights reserved.
4+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
45
#
56
# Licensed under the Apache License, Version 2.0 (the License); you may not use
67
# this file except in compliance with the License. You may obtain a copy of the
78
# License at http://www.apache.org/licenses/LICENSE-2.0
89
#
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
917
# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
1018
# OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
1119
# IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
1220
# MERCHANTABLITY OR NON-INFRINGEMENT.
21+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
1322
#
23+
=======
24+
#
25+
>>>>>>> unitests using python unittest framework #239
1426
# See the Apache Version 2.0 License for specific language governing
1527
# permissions and limitations under the License.
1628

@@ -43,11 +55,19 @@ def __init__(self, old_out, is_stdout):
4355
def flush(self):
4456
if self.old_out:
4557
self.old_out.flush()
58+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
4659

4760
def writelines(self, lines):
4861
for line in lines:
4962
self.write(line)
5063

64+
=======
65+
66+
def writelines(self, lines):
67+
for line in lines:
68+
self.write(line)
69+
70+
>>>>>>> unitests using python unittest framework #239
5171
@property
5272
def encoding(self):
5373
return 'utf8'
@@ -56,15 +76,23 @@ def write(self, value):
5676
_channel.send_event('stdout' if self.is_stdout else 'stderr', content=value)
5777
if self.old_out:
5878
self.old_out.write(value)
79+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
5980
# flush immediately, else things go wonky and out of order
6081
self.flush()
6182

83+
=======
84+
85+
>>>>>>> unitests using python unittest framework #239
6286
def isatty(self):
6387
return True
6488

6589
def next(self):
6690
pass
91+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
6792

93+
=======
94+
95+
>>>>>>> unitests using python unittest framework #239
6896
@property
6997
def name(self):
7098
if self.is_stdout:
@@ -84,7 +112,11 @@ def write(self, data):
84112
_channel.send_event('stdout' if self.is_stdout else 'stderr', content=data)
85113
self.buffer.write(data)
86114

115+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
87116
def flush(self):
117+
=======
118+
def flush(self):
119+
>>>>>>> unitests using python unittest framework #239
88120
self.buffer.flush()
89121

90122
def truncate(self, pos = None):
@@ -129,13 +161,21 @@ def startTest(self, test):
129161
super(VsTestResult, self).startTest(test)
130162
if _channel is not None:
131163
_channel.send_event(
164+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
132165
name='start',
166+
=======
167+
name='start',
168+
>>>>>>> unitests using python unittest framework #239
133169
test = test.id()
134170
)
135171

136172
def addError(self, test, err):
137173
super(VsTestResult, self).addError(test, err)
174+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
138175
self.sendResult(test, 'error', err)
176+
=======
177+
self.sendResult(test, 'failed', err)
178+
>>>>>>> unitests using python unittest framework #239
139179

140180
def addFailure(self, test, err):
141181
super(VsTestResult, self).addFailure(test, err)
@@ -169,7 +209,11 @@ def sendResult(self, test, outcome, trace = None):
169209
tb = ''.join(formatted)
170210
message = str(trace[1])
171211
_channel.send_event(
212+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
172213
name='result',
214+
=======
215+
name='result',
216+
>>>>>>> unitests using python unittest framework #239
173217
outcome=outcome,
174218
traceback = tb,
175219
message = message,
@@ -182,7 +226,11 @@ def stopTests():
182226
class ExitCommand(Exception):
183227
pass
184228

229+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
185230
def signal_handler(signal, frame):
231+
=======
232+
def signal_handler(signal, frame):
233+
>>>>>>> unitests using python unittest framework #239
186234
raise ExitCommand()
187235

188236
def main():
@@ -202,11 +250,19 @@ def main():
202250
parser.add_option('--us', type='str', help='Directory to start discovery')
203251
parser.add_option('--up', type='str', help='Pattern to match test files (''test*.py'' default)')
204252
parser.add_option('--ut', type='str', help='Top level directory of project (default to start directory)')
253+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
205254
parser.add_option('--uvInt', '--verboseInt', type='int', help='Verbose output (0 none, 1 (no -v) simple, 2 (-v) full)')
206255
parser.add_option('--uf', '--failfast', type='str', help='Stop on first failure')
207256
parser.add_option('--uc', '--catch', type='str', help='Catch control-C and display results')
208257
(opts, _) = parser.parse_args()
209258

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
210266
sys.path[0] = os.getcwd()
211267
if opts.result_port:
212268
signal.signal(signal.SIGUSR1, signal_handler)
@@ -224,7 +280,11 @@ def main():
224280
enable_attach(opts.secret, ('127.0.0.1', getattr(opts, 'port', DEFAULT_PORT)), redirect_output = True)
225281
wait_for_attach()
226282
elif opts.mixed_mode:
283+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
227284
# 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
228288
# so we have to use Win32 API in a loop to do the same thing.
229289
from time import sleep
230290
from ctypes import windll, c_char
@@ -265,8 +325,14 @@ def main():
265325
runner = unittest.TextTestRunner(verbosity=opts.uvInt, resultclass=VsTestResult)
266326
if opts.uf is not None:
267327
runner.failfast = 1
328+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
268329

269330
result = runner.run(tests)
331+
=======
332+
333+
result = runner.run(tests)
334+
335+
>>>>>>> unitests using python unittest framework #239
270336
sys.exit(not result.wasSuccessful())
271337
finally:
272338
if cov is not None:
@@ -278,6 +344,7 @@ def main():
278344
name='done'
279345
)
280346
_channel.socket.close()
347+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
281348
# prevent generation of the error 'Error in sys.exitfunc:'
282349
try:
283350
sys.stdout.close()
@@ -287,6 +354,8 @@ def main():
287354
sys.stderr.close()
288355
except:
289356
pass
357+
=======
358+
>>>>>>> unitests using python unittest framework #239
290359

291360
if __name__ == '__main__':
292361
main()

src/client/unittests/unittest/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ export class TestManager extends BaseTestManager {
2323
return fn.testFunction.status === TestStatus.Error || fn.testFunction.status === TestStatus.Fail;
2424
}).map(fn=>fn.testFunction);
2525
}
26+
<<<<<<< a3034a0dafa547afd949f2b0dcbdcba6accb5764
2627

28+
=======
29+
30+
>>>>>>> unitests using python unittest framework #239
2731
return runTest(this.rootDirectory, tests, args, testsToRun, this.cancellationToken, this.outputChannel);
2832
}
2933
}

0 commit comments

Comments
 (0)