Beispiel #1
0
 def test_help(self):
     for opt in '-h', '--help':
         with self.subTest(opt=opt):
             with support.captured_stdout() as out, \
                  self.assertRaises(SystemExit):
                 libregrtest._parse_args([opt])
             self.assertIn('Run Python regression tests.', out.getvalue())
Beispiel #2
0
 def test_failfast(self):
     for opt in '-G', '--failfast':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, '-v'])
             self.assertTrue(ns.failfast)
             ns = libregrtest._parse_args([opt, '-W'])
             self.assertTrue(ns.failfast)
             self.checkError([opt], '-G/--failfast needs either -v or -W')
Beispiel #3
0
 def test_failfast(self):
     for opt in "-G", "--failfast":
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, "-v"])
             self.assertTrue(ns.failfast)
             ns = libregrtest._parse_args([opt, "-W"])
             self.assertTrue(ns.failfast)
             self.checkError([opt], "-G/--failfast needs either -v or -W")
Beispiel #4
0
 def test_verbose(self):
     ns = libregrtest._parse_args(["-v"])
     self.assertEqual(ns.verbose, 1)
     ns = libregrtest._parse_args(["-vvv"])
     self.assertEqual(ns.verbose, 3)
     ns = libregrtest._parse_args(["--verbose"])
     self.assertEqual(ns.verbose, 1)
     ns = libregrtest._parse_args(["--verbose"] * 3)
     self.assertEqual(ns.verbose, 3)
     ns = libregrtest._parse_args([])
     self.assertEqual(ns.verbose, 0)
Beispiel #5
0
 def test_verbose(self):
     ns = libregrtest._parse_args(['-v'])
     self.assertEqual(ns.verbose, 1)
     ns = libregrtest._parse_args(['-vvv'])
     self.assertEqual(ns.verbose, 3)
     ns = libregrtest._parse_args(['--verbose'])
     self.assertEqual(ns.verbose, 1)
     ns = libregrtest._parse_args(['--verbose'] * 3)
     self.assertEqual(ns.verbose, 3)
     ns = libregrtest._parse_args([])
     self.assertEqual(ns.verbose, 0)
Beispiel #6
0
 def test_use(self):
     for opt in "-u", "--use":
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, "gui,network"])
             self.assertEqual(ns.use_resources, ["gui", "network"])
             ns = libregrtest._parse_args([opt, "gui,none,network"])
             self.assertEqual(ns.use_resources, ["network"])
             expected = list(libregrtest.RESOURCE_NAMES)
             expected.remove("gui")
             ns = libregrtest._parse_args([opt, "all,-gui"])
             self.assertEqual(ns.use_resources, expected)
             self.checkError([opt], "expected one argument")
             self.checkError([opt, "foo"], "invalid resource")
Beispiel #7
0
 def test_use(self):
     for opt in '-u', '--use':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, 'gui,network'])
             self.assertEqual(ns.use_resources, ['gui', 'network'])
             ns = libregrtest._parse_args([opt, 'gui,none,network'])
             self.assertEqual(ns.use_resources, ['network'])
             expected = list(libregrtest.RESOURCE_NAMES)
             expected.remove('gui')
             ns = libregrtest._parse_args([opt, 'all,-gui'])
             self.assertEqual(ns.use_resources, expected)
             self.checkError([opt], 'expected one argument')
             self.checkError([opt, 'foo'], 'invalid resource')
Beispiel #8
0
 def test_huntrleaks(self):
     for opt in "-R", "--huntrleaks":
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, ":"])
             self.assertEqual(ns.huntrleaks, (5, 4, "reflog.txt"))
             ns = libregrtest._parse_args([opt, "6:"])
             self.assertEqual(ns.huntrleaks, (6, 4, "reflog.txt"))
             ns = libregrtest._parse_args([opt, ":3"])
             self.assertEqual(ns.huntrleaks, (5, 3, "reflog.txt"))
             ns = libregrtest._parse_args([opt, "6:3:leaks.log"])
             self.assertEqual(ns.huntrleaks, (6, 3, "leaks.log"))
             self.checkError([opt], "expected one argument")
             self.checkError([opt, "6"], "needs 2 or 3 colon-separated arguments")
             self.checkError([opt, "foo:"], "invalid huntrleaks value")
             self.checkError([opt, "6:foo"], "invalid huntrleaks value")
Beispiel #9
0
 def test_fromfile(self):
     for opt in "-f", "--fromfile":
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, "foo"])
             self.assertEqual(ns.fromfile, "foo")
             self.checkError([opt], "expected one argument")
             self.checkError([opt, "foo", "-s"], "don't go together")
Beispiel #10
0
 def test_huntrleaks(self):
     for opt in '-R', '--huntrleaks':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, ':'])
             self.assertEqual(ns.huntrleaks, (5, 4, 'reflog.txt'))
             ns = libregrtest._parse_args([opt, '6:'])
             self.assertEqual(ns.huntrleaks, (6, 4, 'reflog.txt'))
             ns = libregrtest._parse_args([opt, ':3'])
             self.assertEqual(ns.huntrleaks, (5, 3, 'reflog.txt'))
             ns = libregrtest._parse_args([opt, '6:3:leaks.log'])
             self.assertEqual(ns.huntrleaks, (6, 3, 'leaks.log'))
             self.checkError([opt], 'expected one argument')
             self.checkError([opt, '6'],
                             'needs 2 or 3 colon-separated arguments')
             self.checkError([opt, 'foo:'], 'invalid huntrleaks value')
             self.checkError([opt, '6:foo'], 'invalid huntrleaks value')
Beispiel #11
0
 def test_coverdir(self):
     for opt in '-D', '--coverdir':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, 'foo'])
             self.assertEqual(ns.coverdir,
                              os.path.join(support.SAVEDCWD, 'foo'))
             self.checkError([opt], 'expected one argument')
Beispiel #12
0
 def test_threshold(self):
     for opt in '-t', '--threshold':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, '1000'])
             self.assertEqual(ns.threshold, 1000)
             self.checkError([opt], 'expected one argument')
             self.checkError([opt, 'foo'], 'invalid int value')
Beispiel #13
0
 def test_fromfile(self):
     for opt in '-f', '--fromfile':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, 'foo'])
             self.assertEqual(ns.fromfile, 'foo')
             self.checkError([opt], 'expected one argument')
             self.checkError([opt, 'foo', '-s'], "don't go together")
Beispiel #14
0
 def test_threshold(self):
     for opt in "-t", "--threshold":
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, "1000"])
             self.assertEqual(ns.threshold, 1000)
             self.checkError([opt], "expected one argument")
             self.checkError([opt, "foo"], "invalid int value")
Beispiel #15
0
 def test_nowindows(self):
     for opt in '-n', '--nowindows':
         with self.subTest(opt=opt):
             with contextlib.redirect_stderr(io.StringIO()) as stderr:
                 ns = libregrtest._parse_args([opt])
             self.assertTrue(ns.nowindows)
             err = stderr.getvalue()
             self.assertIn('the --nowindows (-n) option is deprecated', err)
Beispiel #16
0
 def test_multiprocess(self):
     for opt in "-j", "--multiprocess":
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, "2"])
             self.assertEqual(ns.use_mp, 2)
             self.checkError([opt], "expected one argument")
             self.checkError([opt, "foo"], "invalid int value")
             self.checkError([opt, "2", "-T"], "don't go together")
             self.checkError([opt, "2", "-l"], "don't go together")
Beispiel #17
0
 def test_multiprocess(self):
     for opt in '-j', '--multiprocess':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, '2'])
             self.assertEqual(ns.use_mp, 2)
             self.checkError([opt], 'expected one argument')
             self.checkError([opt, 'foo'], 'invalid int value')
             self.checkError([opt, '2', '-T'], "don't go together")
             self.checkError([opt, '2', '-l'], "don't go together")
Beispiel #18
0
    def test_match(self):
        for opt in '-m', '--match':
            with self.subTest(opt=opt):
                ns = libregrtest._parse_args([opt, 'pattern'])
                self.assertEqual(ns.match_tests, ['pattern'])
                self.checkError([opt], 'expected one argument')

        ns = libregrtest._parse_args(['-m', 'pattern1',
                                      '-m', 'pattern2'])
        self.assertEqual(ns.match_tests, ['pattern1', 'pattern2'])

        self.addCleanup(support.unlink, support.TESTFN)
        with open(support.TESTFN, "w") as fp:
            print('matchfile1', file=fp)
            print('matchfile2', file=fp)

        filename = os.path.abspath(support.TESTFN)
        ns = libregrtest._parse_args(['-m', 'match',
                                      '--matchfile', filename])
        self.assertEqual(ns.match_tests,
                         ['match', 'matchfile1', 'matchfile2'])
Beispiel #19
0
    def test_use(self):
        for opt in '-u', '--use':
            with self.subTest(opt=opt):
                ns = libregrtest._parse_args([opt, 'gui,network'])
                self.assertEqual(ns.use_resources, ['gui', 'network'])

                ns = libregrtest._parse_args([opt, 'gui,none,network'])
                self.assertEqual(ns.use_resources, ['network'])

                expected = list(libregrtest.ALL_RESOURCES)
                expected.remove('gui')
                ns = libregrtest._parse_args([opt, 'all,-gui'])
                self.assertEqual(ns.use_resources, expected)
                self.checkError([opt], 'expected one argument')
                self.checkError([opt, 'foo'], 'invalid resource')

                # all + a resource not part of "all"
                ns = libregrtest._parse_args([opt, 'all,tzdata'])
                self.assertEqual(ns.use_resources,
                                 list(libregrtest.ALL_RESOURCES) + ['tzdata'])

                # test another resource which is not part of "all"
                ns = libregrtest._parse_args([opt, 'extralargefile'])
                self.assertEqual(ns.use_resources, ['extralargefile'])
Beispiel #20
0
 def test_option_with_empty_string_value(self):
     ns = libregrtest._parse_args(['--start', ''])
     self.assertEqual(ns.start, '')
Beispiel #21
0
 def test_long_option__partial(self):
     ns = libregrtest._parse_args(['--qui'])
     self.assertTrue(ns.quiet)
     self.assertEqual(ns.verbose, 0)
Beispiel #22
0
 def test_option_with_empty_string_value(self):
     ns = libregrtest._parse_args(['--start', ''])
     self.assertEqual(ns.start, '')
Beispiel #23
0
 def test_single(self):
     for opt in '-s', '--single':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt])
             self.assertTrue(ns.single)
             self.checkError([opt, '-f', 'foo'], "don't go together")
Beispiel #24
0
 def test_timeout(self):
     ns = libregrtest._parse_args(['--timeout', '4.2'])
     self.assertEqual(ns.timeout, 4.2)
     self.checkError(['--timeout'], 'expected one argument')
     self.checkError(['--timeout', 'foo'], 'invalid float value')
Beispiel #25
0
 def test_quiet(self):
     for opt in '-q', '--quiet':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt])
             self.assertTrue(ns.quiet)
             self.assertEqual(ns.verbose, 0)
Beispiel #26
0
 def test_verbose3(self):
     for opt in '-W', '--verbose3':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt])
             self.assertTrue(ns.verbose3)
Beispiel #27
0
 def test_start(self):
     for opt in '-S', '--start':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, 'foo'])
             self.assertEqual(ns.start, 'foo')
             self.checkError([opt], 'expected one argument')
Beispiel #28
0
 def test_worker_args(self):
     ns = libregrtest._parse_args(['--worker-args', '[[], {}]'])
     self.assertEqual(ns.worker_args, '[[], {}]')
     self.checkError(['--worker-args'], 'expected one argument')
Beispiel #29
0
 def test_wait(self):
     ns = libregrtest._parse_args(['--wait'])
     self.assertTrue(ns.wait)
Beispiel #30
0
 def test_timeout(self):
     ns = libregrtest._parse_args(['--timeout', '4.2'])
     self.assertEqual(ns.timeout, 4.2)
     self.checkError(['--timeout'], 'expected one argument')
     self.checkError(['--timeout', 'foo'], 'invalid float value')
Beispiel #31
0
 def test_option_and_arg(self):
     ns = libregrtest._parse_args(['--quiet', 'foo'])
     self.assertTrue(ns.quiet)
     self.assertEqual(ns.verbose, 0)
     self.assertEqual(ns.args, ['foo'])
Beispiel #32
0
 def checkError(self, args, msg):
     with support.captured_stderr() as err, self.assertRaises(SystemExit):
         libregrtest._parse_args(args)
     self.assertIn(msg, err.getvalue())
Beispiel #33
0
 def test_slow(self):
     for opt in '-o', '--slowest':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt])
             self.assertTrue(ns.print_slow)
Beispiel #34
0
 def checkError(self, args, msg):
     with support.captured_stderr() as err, self.assertRaises(SystemExit):
         libregrtest._parse_args(args)
     self.assertIn(msg, err.getvalue())
Beispiel #35
0
 def test_header(self):
     ns = libregrtest._parse_args(['--header'])
     self.assertTrue(ns.header)
Beispiel #36
0
 def test_option_and_arg(self):
     ns = libregrtest._parse_args(['--quiet', 'foo'])
     self.assertTrue(ns.quiet)
     self.assertEqual(ns.verbose, 0)
     self.assertEqual(ns.args, ['foo'])
Beispiel #37
0
 def test_randomize(self):
     for opt in '-r', '--randomize':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt])
             self.assertTrue(ns.randomize)
Beispiel #38
0
 def test_exclude(self):
     for opt in '-x', '--exclude':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt])
             self.assertTrue(ns.exclude)
Beispiel #39
0
 def test_coverage(self):
     for opt in '-T', '--coverage':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt])
             self.assertTrue(ns.trace)
Beispiel #40
0
 def test_arg(self):
     ns = libregrtest._parse_args(['foo'])
     self.assertEqual(ns.args, ['foo'])
Beispiel #41
0
 def test_match(self):
     for opt in '-m', '--match':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, 'pattern'])
             self.assertEqual(ns.match_tests, 'pattern')
             self.checkError([opt], 'expected one argument')
Beispiel #42
0
 def test_two_options(self):
     ns = libregrtest._parse_args(['--quiet', '--exclude'])
     self.assertTrue(ns.quiet)
     self.assertEqual(ns.verbose, 0)
     self.assertTrue(ns.exclude)
Beispiel #43
0
 def test_runleaks(self):
     for opt in '-L', '--runleaks':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt])
             self.assertTrue(ns.runleaks)
Beispiel #44
0
 def test_two_options(self):
     ns = libregrtest._parse_args(['--quiet', '--exclude'])
     self.assertTrue(ns.quiet)
     self.assertEqual(ns.verbose, 0)
     self.assertTrue(ns.exclude)
Beispiel #45
0
 def test_testdir(self):
     ns = libregrtest._parse_args(['--testdir', 'foo'])
     self.assertEqual(ns.testdir, os.path.join(support.SAVEDCWD, 'foo'))
     self.checkError(['--testdir'], 'expected one argument')
Beispiel #46
0
 def test_arg(self):
     ns = libregrtest._parse_args(['foo'])
     self.assertEqual(ns.args, ['foo'])
Beispiel #47
0
 def test_worker_args(self):
     ns = libregrtest._parse_args(['--worker-args', '[[], {}]'])
     self.assertEqual(ns.worker_args, '[[], {}]')
     self.checkError(['--worker-args'], 'expected one argument')
Beispiel #48
0
 def test_arg_option_arg(self):
     ns = libregrtest._parse_args(['test_unaryop', '-v', 'test_binop'])
     self.assertEqual(ns.verbose, 1)
     self.assertEqual(ns.args, ['test_unaryop', 'test_binop'])
Beispiel #49
0
 def test_forever(self):
     for opt in '-F', '--forever':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt])
             self.assertTrue(ns.forever)
Beispiel #50
0
 def test_randseed(self):
     ns = libregrtest._parse_args(['--randseed', '12345'])
     self.assertEqual(ns.random_seed, 12345)
     self.assertTrue(ns.randomize)
     self.checkError(['--randseed'], 'expected one argument')
     self.checkError(['--randseed', 'foo'], 'invalid int value')
Beispiel #51
0
 def test_memlimit(self):
     for opt in '-M', '--memlimit':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, '4G'])
             self.assertEqual(ns.memlimit, '4G')
             self.checkError([opt], 'expected one argument')
Beispiel #52
0
 def test_wait(self):
     ns = libregrtest._parse_args(['--wait'])
     self.assertTrue(ns.wait)
Beispiel #53
0
 def test_arg_option_arg(self):
     ns = libregrtest._parse_args(['test_unaryop', '-v', 'test_binop'])
     self.assertEqual(ns.verbose, 1)
     self.assertEqual(ns.args, ['test_unaryop', 'test_binop'])
Beispiel #54
0
 def test_start(self):
     for opt in '-S', '--start':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt, 'foo'])
             self.assertEqual(ns.start, 'foo')
             self.checkError([opt], 'expected one argument')
Beispiel #55
0
 def test_nocoverdir(self):
     for opt in '-N', '--nocoverdir':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt])
             self.assertIsNone(ns.coverdir)
Beispiel #56
0
 def test_verbose3(self):
     for opt in '-W', '--verbose3':
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt])
             self.assertTrue(ns.verbose3)
Beispiel #57
0
 def test_verbose2(self):
     for opt in ('-w', '--verbose2'):
         with self.subTest(opt=opt):
             ns = libregrtest._parse_args([opt])
             self.assertTrue(ns.verbose2)