@@ -0,0 +1,2014 @@
+from nose2 import options%0Afrom nose2.compat import unittest%0A%0A%0Aclass TestMultipassOptionParser(unittest.TestCase):%0A%0A    def setUp(self):%0A        self.p = options.MultipassOptionParser()%0A%0A    def test_parser_leaves_unhandled_arguments(self):%0A        args, argv = self.p.parse_args(%5B'-x', 'foo', 'bar', '--this=that'%5D)%0A        self.assertEqual(argv, %5B'-x', 'foo', 'bar', '--this=that'%5D)%0A%0A    def test_parser_can_extract_test_names(self):%0A        self.p.add_argument('tests', nargs='*', default=%5B%5D)%0A        args, argv = self.p.parse_args(%5B'-x', 'foo', 'bar'%5D)%0A        print args, argv%0A        self.assertEqual(argv, %5B'-x'%5D)%0A        self.assertEqual(args.tests, %5B'foo', 'bar'%5D)%0A%0A    def test_parser_can_extract_config_files_then_tests(self):%0A        self.p.add_argument(%0A            '--config', '-c', nargs='?', action='append', default=%5B%5D)%0A        args, argv = self.p.parse_args(%5B'-x', 'foo', '-c', 'conf.cfg',%0A                                        'bar', '--this=that'%5D)%0A        self.assertEqual(args.config, %5B'conf.cfg'%5D)%0A        self.assertEqual(argv, %5B'-x', 'foo', 'bar', '--this=that'%5D)%0A        self.p.add_argument('tests', nargs='*', default=%5B%5D)%0A        args2, argv2 = self.p.parse_args(argv)%0A        self.assertEqual(argv2, %5B'-x', '--this=that'%5D)%0A        self.assertEqual(args2.tests, %5B'foo', 'bar'%5D)%0A%0A    def test_parser_can_extract_config_files_then_options_then_tests(self):%0A        self.p.add_argument(%0A            '--config', '-c', nargs='?', action='append', default=%5B%5D)%0A        args, argv = self.p.parse_args(%5B'-x', 'foo', '-c', 'conf.cfg',%0A                                        'bar', '--this=that'%5D)%0A        self.assertEqual(args.config, %5B'conf.cfg'%5D)%0A        self.assertEqual(argv, %5B'-x', 'foo', 'bar', '--this=that'%5D)%0A        self.p.add_argument('-x')%0A        self.p.add_argument('tests', nargs='*', default=%5B%5D)%0A        args2, argv2 = self.p.parse_args(argv)%0A        self.assertEqual(args2.x, 'foo')%0A        self.assertEqual(argv2, %5B'--this=that'%5D)%0A        self.assertEqual(args2.tests, %5B'bar'%5D)%0A

Add unit tests for options module