def testQuick(self):
     """Verify --quick filters out slow tests"""
     self.PatchObject(run_tests, 'RunTests', return_value=True)
     # Pick a test that is in SLOW_TESTS but not in SPECIAL_TESTS.
     slow_test = 'lib/patch_unittest'
     self.assertIn(slow_test, run_tests.SLOW_TESTS)
     self.assertNotIn(slow_test, run_tests.SPECIAL_TESTS)
     run_tests.main(['--quick'])
     self.assertIn(slow_test, run_tests.SPECIAL_TESTS)
 def testList(self):
     """Verify --list works"""
     self.PatchObject(run_tests,
                      'RunTests',
                      side_effect=Exception('do not run'))
     with self.OutputCapturer() as output:
         run_tests.main(['--list'])
         # Verify some reasonable number of lines showed up.
         self.assertGreater(len(output.GetStdoutLines()), 90)
 def testSpecificTests(self):
     """Verify user specified tests are run."""
     m = self.PatchObject(run_tests, 'RunTests', return_value=True)
     tests = ['./some/foo_unittest', './bar_unittest']
     run_tests.main(tests)
     m.assert_called_with(tests,
                          jobs=mock.ANY,
                          chroot_available=mock.ANY,
                          network=mock.ANY,
                          dryrun=mock.ANY,
                          failfast=mock.ANY,
                          pyver=mock.ANY)
 def testUnknownArg(self):
     """Verify we kick out unknown args"""
     self.PatchObject(run_tests,
                      'RunTests',
                      side_effect=Exception('do not run'))
     bad_arg = '--foasdf'
     exit_code = None
     # Only run the main code w/the capturer enabled so we don't swallow
     # general test output.
     with self.OutputCapturer():
         try:
             run_tests.main([bad_arg])
         except SystemExit as e:
             exit_code = e.code
     self.assertNotEqual(exit_code,
                         0,
                         msg='run_tests wrongly accepted %s' % bad_arg)
 def testMisc(self):
     """Verify basic flags get passed down correctly"""
     m = self.PatchObject(run_tests, 'RunTests', return_value=True)
     run_tests.main(['--network'])
     m.assert_called_with(mock.ANY,
                          jobs=mock.ANY,
                          chroot_available=mock.ANY,
                          network=True,
                          config_skew=False,
                          dryrun=False,
                          failfast=False,
                          pyver=None)
     run_tests.main(['--config_skew'])
     m.assert_called_with(mock.ANY,
                          jobs=mock.ANY,
                          chroot_available=mock.ANY,
                          network=False,
                          config_skew=True,
                          dryrun=False,
                          failfast=False,
                          pyver=None)
     run_tests.main(['--dry-run'])
     m.assert_called_with(mock.ANY,
                          jobs=mock.ANY,
                          chroot_available=mock.ANY,
                          network=False,
                          config_skew=False,
                          dryrun=True,
                          failfast=False,
                          pyver=None)
     run_tests.main(['--jobs', '1000'])
     m.assert_called_with(mock.ANY,
                          jobs=1000,
                          chroot_available=mock.ANY,
                          network=False,
                          config_skew=False,
                          dryrun=False,
                          failfast=False,
                          pyver=None)
     run_tests.main(['--failfast'])
     m.assert_called_with(mock.ANY,
                          jobs=mock.ANY,
                          chroot_available=mock.ANY,
                          network=False,
                          config_skew=False,
                          dryrun=False,
                          failfast=True,
                          pyver=None)
     run_tests.main(['--py2'])
     m.assert_called_with(mock.ANY,
                          jobs=mock.ANY,
                          chroot_available=mock.ANY,
                          network=False,
                          config_skew=False,
                          dryrun=False,
                          failfast=False,
                          pyver='py2')
     run_tests.main(['--py3'])
     m.assert_called_with(mock.ANY,
                          jobs=mock.ANY,
                          chroot_available=mock.ANY,
                          network=False,
                          config_skew=False,
                          dryrun=False,
                          failfast=False,
                          pyver='py3')