1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00
pip/tests/lib/options_helpers.py
2018-07-30 09:32:47 +05:30

33 lines
788 B
Python

"""Provides helper classes for testing option handling in pip
"""
import os
from pip._internal import cmdoptions
from pip._internal.cli.base_command import Command
from pip._internal.commands import commands_dict
class FakeCommand(Command):
name = 'fake'
summary = name
def main(self, args):
index_opts = cmdoptions.make_option_group(
cmdoptions.index_group,
self.parser,
)
self.parser.add_option_group(index_opts)
return self.parse_args(args)
class AddFakeCommandMixin(object):
def setup(self):
self.environ_before = os.environ.copy()
commands_dict[FakeCommand.name] = FakeCommand
def teardown(self):
os.environ = self.environ_before
commands_dict.pop(FakeCommand.name)