本文整理汇总了Python中test.libregrtest._parse_args函数的典型用法代码示例。如果您正苦于以下问题:Python _parse_args函数的具体用法?Python _parse_args怎么用?Python _parse_args使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_parse_args函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_help
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())
示例2: test_failfast
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")
示例3: test_verbose
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)
示例4: test_use
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')
示例5: test_huntrleaks
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")
示例6: test_fromfile
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")
示例7: test_threshold
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")
示例8: test_huntrleaks
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')
示例9: test_coverdir
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')
示例10: test_nowindows
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)
示例11: test_multiprocess
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")
示例12: test_match
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'])
示例13: test_use
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'])
示例14: test_start
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')
示例15: test_worker_args
def test_worker_args(self):
ns = libregrtest._parse_args(['--worker-args', '[[], {}]'])
self.assertEqual(ns.worker_args, '[[], {}]')
self.checkError(['--worker-args'], 'expected one argument')