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

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

Issue 2690743002: Roll typ v0.9.9 -> v0.9.11 (5822dda0..f6afa2bb). (Closed)
Patch Set: Created 3 years, 10 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 | « third_party/typ/typ/tests/json_results_test.py ('k') | third_party/typ/typ/version.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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 rout=(r'\[1/1\] pass_test.PassingTest.test_pass passed ' 615 rout=(r'\[1/1\] pass_test.PassingTest.test_pass passed '
616 r'\d+.\d+s\n' 616 r'\d+.\d+s\n'
617 r'1 test run in \d+.\d+s, 0 failures.')) 617 r'1 test run in \d+.\d+s, 0 failures.'))
618 618
619 def test_test_results_server(self): 619 def test_test_results_server(self):
620 server = test_result_server_fake.start() 620 server = test_result_server_fake.start()
621 self.assertNotEqual(server, None, 'could not start fake server') 621 self.assertNotEqual(server, None, 'could not start fake server')
622 622
623 try: 623 try:
624 self.check(['--test-results-server', 624 self.check(['--test-results-server',
625 '%s:%d' % server.server_address, 625 'http://%s:%d' % server.server_address,
626 '--master-name', 'fake_master', 626 '--master-name', 'fake_master',
627 '--builder-name', 'fake_builder', 627 '--builder-name', 'fake_builder',
628 '--test-type', 'typ_tests', 628 '--test-type', 'typ_tests',
629 '--metadata', 'foo=bar'], 629 '--metadata', 'foo=bar'],
630 files=PASS_TEST_FILES, ret=0, err='', 630 files=PASS_TEST_FILES, ret=0, err='',
631 out=('[1/1] pass_test.PassingTest.test_pass passed\n' 631 out=('[1/1] pass_test.PassingTest.test_pass passed\n'
632 '1 test run, 0 failures.\n')) 632 '1 test run, 0 failures.\n'))
633 633
634 finally: 634 finally:
635 posts = server.stop() 635 posts = server.stop()
636 636
637 self.assertEqual(len(posts), 1) 637 self.assertEqual(len(posts), 1)
638 payload = posts[0][2].decode('utf8') 638 payload = posts[0][2].decode('utf8')
639 self.assertIn('"test_pass": {"actual": "PASS", "expected": "PASS"}', 639 self.assertIn('"test_pass": {"actual": "PASS"',
640 payload) 640 payload)
641 self.assertTrue(payload.endswith('--\r\n')) 641 self.assertTrue(payload.endswith('--\r\n'))
642 self.assertNotEqual(server.log.getvalue(), '') 642 self.assertNotEqual(server.log.getvalue(), '')
643 643
644 def test_test_results_server_error(self): 644 def test_test_results_server_error(self):
645 server = test_result_server_fake.start(code=500) 645 server = test_result_server_fake.start(code=500)
646 self.assertNotEqual(server, None, 'could not start fake server') 646 self.assertNotEqual(server, None, 'could not start fake server')
647 647
648 try: 648 try:
649 self.check(['--test-results-server', 649 self.check(['--test-results-server',
650 '%s:%d' % server.server_address, 650 'http://%s:%d' % server.server_address,
651 '--master-name', 'fake_master', 651 '--master-name', 'fake_master',
652 '--builder-name', 'fake_builder', 652 '--builder-name', 'fake_builder',
653 '--test-type', 'typ_tests', 653 '--test-type', 'typ_tests',
654 '--metadata', 'foo=bar'], 654 '--metadata', 'foo=bar'],
655 files=PASS_TEST_FILES, ret=1, err='', 655 files=PASS_TEST_FILES, ret=1, err='',
656 out=('[1/1] pass_test.PassingTest.test_pass passed\n' 656 out=('[1/1] pass_test.PassingTest.test_pass passed\n'
657 '1 test run, 0 failures.\n' 657 '1 test run, 0 failures.\n'
658 'Uploading the JSON results raised ' 658 'Uploading the JSON results raised '
659 '"HTTP Error 500: Internal Server Error"\n')) 659 '"HTTP Error 500: Internal Server Error"\n'))
660 660
661 finally: 661 finally:
662 _ = server.stop() 662 _ = server.stop()
663 663
664 def test_test_results_server_not_running(self): 664 def test_test_results_server_not_running(self):
665 self.check(['--test-results-server', 'localhost:99999', 665 self.check(['--test-results-server', 'http://localhost:99999',
666 '--master-name', 'fake_master', 666 '--master-name', 'fake_master',
667 '--builder-name', 'fake_builder', 667 '--builder-name', 'fake_builder',
668 '--test-type', 'typ_tests', 668 '--test-type', 'typ_tests',
669 '--metadata', 'foo=bar'], 669 '--metadata', 'foo=bar'],
670 files=PASS_TEST_FILES, ret=1, err='', 670 files=PASS_TEST_FILES, ret=1, err='',
671 rout=(r'\[1/1\] pass_test.PassingTest.test_pass passed\n' 671 rout=(r'\[1/1\] pass_test.PassingTest.test_pass passed\n'
672 '1 test run, 0 failures.\n' 672 '1 test run, 0 failures.\n'
673 'Uploading the JSON results raised .*\n')) 673 'Uploading the JSON results raised .*\n'))
674 674
675 def test_verbose_2(self): 675 def test_verbose_2(self):
(...skipping 23 matching lines...) Expand all
699 def test_version(self): 699 def test_version(self):
700 self.check('--version', ret=0, out=(VERSION + '\n')) 700 self.check('--version', ret=0, out=(VERSION + '\n'))
701 701
702 def test_write_full_results_to(self): 702 def test_write_full_results_to(self):
703 _, _, _, files = self.check(['--write-full-results-to', 703 _, _, _, files = self.check(['--write-full-results-to',
704 'results.json'], files=PASS_TEST_FILES) 704 'results.json'], files=PASS_TEST_FILES)
705 self.assertIn('results.json', files) 705 self.assertIn('results.json', files)
706 results = json.loads(files['results.json']) 706 results = json.loads(files['results.json'])
707 self.assertEqual(results['interrupted'], False) 707 self.assertEqual(results['interrupted'], False)
708 self.assertEqual(results['path_delimiter'], '.') 708 self.assertEqual(results['path_delimiter'], '.')
709
710 # The time it takes to run the test varies, so we test that
711 # we got a single entry greater than zero, but then delete it from
712 # the result so we can do an exact match on the rest of the trie.
713 result = results['tests']['pass_test']['PassingTest']['test_pass']
714 self.assertEqual(len(result['times']), 1)
715 self.assertGreater(result['times'][0], 0)
716 result.pop('times')
709 self.assertEqual(results['tests'], 717 self.assertEqual(results['tests'],
710 {u'pass_test': { 718 {u'pass_test': {
711 u'PassingTest': { 719 u'PassingTest': {
712 u'test_pass': { 720 u'test_pass': {
713 u'actual': u'PASS', 721 u'actual': u'PASS',
714 u'expected': u'PASS', 722 u'expected': u'PASS',
715 } 723 }
716 } 724 }
717 }}) 725 }})
718 726
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 modules_to_unload.append(k) 764 modules_to_unload.append(k)
757 for k in modules_to_unload: 765 for k in modules_to_unload:
758 del sys.modules[k] 766 del sys.modules[k]
759 sys.path = orig_sys_path 767 sys.path = orig_sys_path
760 768
761 return ret, out, err 769 return ret, out, err
762 770
763 def test_debugger(self): 771 def test_debugger(self):
764 # TODO: this test seems to hang under coverage. 772 # TODO: this test seems to hang under coverage.
765 pass 773 pass
OLDNEW
« no previous file with comments | « third_party/typ/typ/tests/json_results_test.py ('k') | third_party/typ/typ/version.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698