def test_pytest_opts(self): tool, cmd, args, toolargs = parse_args( ["discover", "pytest", "--simple", "--no-hide-stdio", "--pretty",] ) self.assertEqual(tool, "pytest") self.assertEqual(cmd, "discover") self.assertEqual(args, {"pretty": True, "hidestdio": False, "simple": True}) self.assertEqual(toolargs, [])
def test_pytest_default(self): tool, cmd, args, toolargs = parse_args([ 'discover', 'pytest', ]) self.assertEqual(tool, 'pytest') self.assertEqual(cmd, 'discover') self.assertEqual(args, {}) self.assertEqual(toolargs, [])
def test_unsupported_tool(self): with self.assertRaises(SystemExit): parse_args(["discover", "unittest"]) with self.assertRaises(SystemExit): parse_args(["discover", "nose"]) with self.assertRaises(SystemExit): parse_args(["discover", "???"])
def test_unsupported_command(self): with self.assertRaises(SystemExit): parse_args(["run", "pytest"]) with self.assertRaises(SystemExit): parse_args(["debug", "pytest"]) with self.assertRaises(SystemExit): parse_args(["???", "pytest"])
def test_unsupported_tool(self): with self.assertRaises(SystemExit): parse_args(['discover', 'unittest']) with self.assertRaises(SystemExit): parse_args(['discover', 'nose']) with self.assertRaises(SystemExit): parse_args(['discover', '???'])
def test_unsupported_command(self): with self.assertRaises(SystemExit): parse_args(['run', 'pytest']) with self.assertRaises(SystemExit): parse_args(['debug', 'pytest']) with self.assertRaises(SystemExit): parse_args(['???', 'pytest'])
def test_pytest_full(self): tool, cmd, args, toolargs = parse_args([ 'discover', 'pytest', # no adapter-specific options yet '--', '--strict', '--ignore', 'spam,ham,eggs', '--pastebin=xyz', '--no-cov', '-d', ]) self.assertEqual(tool, 'pytest') self.assertEqual(cmd, 'discover') self.assertEqual(args, {}) self.assertEqual(toolargs, [ '--', '--strict', '--ignore', 'spam,ham,eggs', '--pastebin=xyz', '--no-cov', '-d', ])
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # Replace the "." entry. import os.path import sys sys.path[0] = os.path.dirname( os.path.dirname( os.path.abspath(__file__))) from testing_tools.adapter.__main__ import parse_args, main if __name__ == '__main__': tool, cmd, subargs, toolargs = parse_args() main(tool, cmd, subargs, toolargs)