| OLD | NEW |
| 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 files=files, ret=0, err='') | 367 files=files, ret=0, err='') |
| 368 self.assertIn('Retrying failed tests (attempt #1 of 3)', out) | 368 self.assertIn('Retrying failed tests (attempt #1 of 3)', out) |
| 369 self.assertNotIn('Retrying failed tests (attempt #2 of 3)', out) | 369 self.assertNotIn('Retrying failed tests (attempt #2 of 3)', out) |
| 370 self.assertIn('1 test run, 0 failures.\n', out) | 370 self.assertIn('1 test run, 0 failures.\n', out) |
| 371 results = json.loads(files['full_results.json']) | 371 results = json.loads(files['full_results.json']) |
| 372 self.assertEqual( | 372 self.assertEqual( |
| 373 results['tests'][ | 373 results['tests'][ |
| 374 'fail_then_pass_test']['FPTest']['test_count']['actual'], | 374 'fail_then_pass_test']['FPTest']['test_count']['actual'], |
| 375 'FAIL PASS') | 375 'FAIL PASS') |
| 376 | 376 |
| 377 def test_fail_then_skip(self): |
| 378 files = {'fail_then_skip_test.py': d("""\ |
| 379 import unittest |
| 380 count = 0 |
| 381 class FPTest(unittest.TestCase): |
| 382 def test_count(self): |
| 383 global count |
| 384 count += 1 |
| 385 if count == 1: |
| 386 self.fail() |
| 387 elif count == 2: |
| 388 self.skipTest('') |
| 389 """)} |
| 390 _, out, _, files = self.check(['--retry-limit', '3', |
| 391 '--write-full-results-to', |
| 392 'full_results.json'], |
| 393 files=files, ret=0, err='') |
| 394 self.assertIn('Retrying failed tests (attempt #1 of 3)', out) |
| 395 self.assertNotIn('Retrying failed tests (attempt #2 of 3)', out) |
| 396 self.assertIn('1 test run, 0 failures.\n', out) |
| 397 results = json.loads(files['full_results.json']) |
| 398 self.assertEqual( |
| 399 results['tests'][ |
| 400 'fail_then_skip_test']['FPTest']['test_count']['actual'], |
| 401 'FAIL SKIP') |
| 402 |
| 377 def test_failures_are_not_elided(self): | 403 def test_failures_are_not_elided(self): |
| 378 _, out, _, _ = self.check(['--terminal-width=20'], | 404 _, out, _, _ = self.check(['--terminal-width=20'], |
| 379 files=FAIL_TEST_FILES, ret=1, err='') | 405 files=FAIL_TEST_FILES, ret=1, err='') |
| 380 self.assertIn('[1/1] fail_test.FailingTest.test_fail failed ' | 406 self.assertIn('[1/1] fail_test.FailingTest.test_fail failed ' |
| 381 'unexpectedly:\n', out) | 407 'unexpectedly:\n', out) |
| 382 | 408 |
| 383 def test_file_list(self): | 409 def test_file_list(self): |
| 384 files = PASS_TEST_FILES | 410 files = PASS_TEST_FILES |
| 385 self.check(['-f', '-'], files=files, stdin='pass_test\n', ret=0) | 411 self.check(['-f', '-'], files=files, stdin='pass_test\n', ret=0) |
| 386 self.check(['-f', '-'], files=files, stdin='pass_test.PassingTest\n', | 412 self.check(['-f', '-'], files=files, stdin='pass_test.PassingTest\n', |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 '--metadata', 'foo=bar'], | 701 '--metadata', 'foo=bar'], |
| 676 files=PASS_TEST_FILES, ret=0, err='', | 702 files=PASS_TEST_FILES, ret=0, err='', |
| 677 out=('[1/1] pass_test.PassingTest.test_pass passed\n' | 703 out=('[1/1] pass_test.PassingTest.test_pass passed\n' |
| 678 '1 test run, 0 failures.\n')) | 704 '1 test run, 0 failures.\n')) |
| 679 | 705 |
| 680 finally: | 706 finally: |
| 681 posts = server.stop() | 707 posts = server.stop() |
| 682 | 708 |
| 683 self.assertEqual(len(posts), 1) | 709 self.assertEqual(len(posts), 1) |
| 684 payload = posts[0][2].decode('utf8') | 710 payload = posts[0][2].decode('utf8') |
| 685 self.assertIn('"test_pass": {"expected": "PASS", "actual": "PASS"}', | 711 self.assertIn('"test_pass": {"actual": "PASS", "expected": "PASS"}', |
| 686 payload) | 712 payload) |
| 687 self.assertTrue(payload.endswith('--\r\n')) | 713 self.assertTrue(payload.endswith('--\r\n')) |
| 688 self.assertNotEqual(server.log.getvalue(), '') | 714 self.assertNotEqual(server.log.getvalue(), '') |
| 689 | 715 |
| 690 def test_test_results_server_error(self): | 716 def test_test_results_server_error(self): |
| 691 server = test_result_server_fake.start(code=500) | 717 server = test_result_server_fake.start(code=500) |
| 692 self.assertNotEqual(server, None, 'could not start fake server') | 718 self.assertNotEqual(server, None, 'could not start fake server') |
| 693 | 719 |
| 694 try: | 720 try: |
| 695 self.check(['--test-results-server', | 721 self.check(['--test-results-server', |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 modules_to_unload.append(k) | 828 modules_to_unload.append(k) |
| 803 for k in modules_to_unload: | 829 for k in modules_to_unload: |
| 804 del sys.modules[k] | 830 del sys.modules[k] |
| 805 sys.path = orig_sys_path | 831 sys.path = orig_sys_path |
| 806 | 832 |
| 807 return ret, out, err | 833 return ret, out, err |
| 808 | 834 |
| 809 def test_debugger(self): | 835 def test_debugger(self): |
| 810 # TODO: this test seems to hang under coverage. | 836 # TODO: this test seems to hang under coverage. |
| 811 pass | 837 pass |
| OLD | NEW |