Beispiel #1
0
    def test_discover(self):
        stub = Stub()
        subparsers = StubSubparsers(stub)
        parser = StubArgParser(stub)
        subparsers.return_add_parser = parser

        add_subparser('discover', 'pytest', subparsers)

        self.assertEqual(stub.calls, [
            ('subparsers.add_parser', None, {'name': 'pytest'}),
            ])
Beispiel #2
0
    def test_discover(self):
        stub = Stub()
        subparsers = StubSubparsers(stub)
        parser = StubArgParser(stub)
        subparsers.return_add_parser = parser

        add_subparser("discover", "pytest", subparsers)

        self.assertEqual(stub.calls, [
            ("subparsers.add_parser", None, {
                "name": "pytest"
            }),
        ])
Beispiel #3
0
    def test_unsupported_command(self):
        subparsers = StubSubparsers(name=None)
        subparsers.return_add_parser = None

        with self.assertRaises(UnsupportedCommandError):
            add_subparser('run', 'pytest', subparsers)
        with self.assertRaises(UnsupportedCommandError):
            add_subparser('debug', 'pytest', subparsers)
        with self.assertRaises(UnsupportedCommandError):
            add_subparser('???', 'pytest', subparsers)
        self.assertEqual(subparsers.calls, [
            ('add_parser', None, {'name': 'pytest'}),
            ('add_parser', None, {'name': 'pytest'}),
            ('add_parser', None, {'name': 'pytest'}),
            ])
Beispiel #4
0
    def test_unsupported_command(self):
        subparsers = StubSubparsers(name=None)
        subparsers.return_add_parser = None

        with self.assertRaises(UnsupportedCommandError):
            add_subparser("run", "pytest", subparsers)
        with self.assertRaises(UnsupportedCommandError):
            add_subparser("debug", "pytest", subparsers)
        with self.assertRaises(UnsupportedCommandError):
            add_subparser("???", "pytest", subparsers)
        self.assertEqual(
            subparsers.calls,
            [
                ("add_parser", None, {
                    "name": "pytest"
                }),
                ("add_parser", None, {
                    "name": "pytest"
                }),
                ("add_parser", None, {
                    "name": "pytest"
                }),
            ],
        )