Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: typ/tests/main_test.py

Issue 2363773008: Add better logging when failing to load a test. (Closed)
Patch Set: patch for review Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « typ/runner.py ('k') | typ/tests/runner_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 Dirk Pranke. All rights reserved. 1 # Copyright 2014 Dirk Pranke. All rights reserved.
2 # 2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 5 # You may obtain a copy of the License at
6 # 6 #
7 # http://www.apache.org/licenses/LICENSE-2.0 7 # http://www.apache.org/licenses/LICENSE-2.0
8 # 8 #
9 # Unless required by applicable law or agreed to in writing, software 9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 10 # distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 ret=0, err='', 351 ret=0, err='',
352 out='foo.pass_test.PassingTest.test_pass\n') 352 out='foo.pass_test.PassingTest.test_pass\n')
353 self.check(['-l', '--path', '../foo', 'pass_test'], 353 self.check(['-l', '--path', '../foo', 'pass_test'],
354 files=files, cwd='bar', ret=0, err='', 354 files=files, cwd='bar', ret=0, err='',
355 out='pass_test.PassingTest.test_pass\n') 355 out='pass_test.PassingTest.test_pass\n')
356 356
357 def test_help(self): 357 def test_help(self):
358 self.check(['--help'], ret=0, rout='.*', err='') 358 self.check(['--help'], ret=0, rout='.*', err='')
359 359
360 def test_import_failure_missing_file(self): 360 def test_import_failure_missing_file(self):
361 self.check(['-l', 'foo'], ret=1, err='', 361 _, out, _, _ = self.check(['-l', 'foo'], ret=1, err='')
362 rout='Failed to load "foo".*') 362 self.assertIn('Failed to load "foo" in find_tests', out)
nednguyen 2016/09/24 01:51:45 Can you assert the out message contains the except
Dirk Pranke 2016/10/11 23:48:33 Done.
363 363
364 def test_import_failure_missing_package(self): 364 def test_import_failure_missing_package(self):
365 files = {'foo.py': d("""\ 365 files = {'foo.py': d("""\
366 import unittest 366 import unittest
367 import package_that_does_not_exist 367 import package_that_does_not_exist
368 368
369 class ImportFailureTest(unittest.TestCase): 369 class ImportFailureTest(unittest.TestCase):
370 def test_case(self): 370 def test_case(self):
371 pass 371 pass
372 """)} 372 """)}
373 self.check(['-l', 'foo.py'], files=files, ret=1, err='', 373 _, out, _, _ = self.check(['-l', 'foo.py'], files=files, ret=1, err='')
374 rout=('Failed to load "foo.py":')) 374 self.assertIn('Failed to load "foo.py" in find_tests', out)
nednguyen 2016/09/24 01:51:45 ditto
Dirk Pranke 2016/10/11 23:48:33 Done.
375 375
376 def test_import_failure_no_tests(self): 376 def test_import_failure_no_tests(self):
377 files = {'foo.py': 'import unittest'} 377 files = {'foo.py': 'import unittest'}
378 self.check(['-l', 'foo.bar'], files=files, ret=1, err='', 378 _, out, _, _ = self.check(['-l', 'foo.bar'], files=files, ret=1, err='')
379 rout='Failed to load "foo.bar":.*') 379 self.assertIn('Failed to load "foo.bar" in find_tests', out)
Dirk Pranke 2016/10/11 23:48:33 I'm not actually sure what I thought I was testing
380 380
381 def test_import_failure_syntax_error(self): 381 def test_import_failure_syntax_error(self):
382 files = {'syn_test.py': d("""\ 382 files = {'syn_test.py': d("""\
383 import unittest 383 import unittest
384 384
385 class SyntaxErrorTest(unittest.TestCase): 385 class SyntaxErrorTest(unittest.TestCase):
386 def test_syntax_error_in_test(self): 386 def test_syntax_error_in_test(self):
387 syntax error 387 syntax error
388 """)} 388 """)}
389 _, out, _, _ = self.check([], files=files, ret=1, err='') 389 _, out, _, _ = self.check([], files=files, ret=1, err='')
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 modules_to_unload.append(k) 754 modules_to_unload.append(k)
755 for k in modules_to_unload: 755 for k in modules_to_unload:
756 del sys.modules[k] 756 del sys.modules[k]
757 sys.path = orig_sys_path 757 sys.path = orig_sys_path
758 758
759 return ret, out, err 759 return ret, out, err
760 760
761 def test_debugger(self): 761 def test_debugger(self):
762 # TODO: this test seems to hang under coverage. 762 # TODO: this test seems to hang under coverage.
763 pass 763 pass
OLDNEW
« no previous file with comments | « typ/runner.py ('k') | typ/tests/runner_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698