mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
1f09e67f34
This resulted in an approximate 24% speed-up of a vanilla `pip` invocation on one system (0.477 secs before, 0.363 secs after).
33 lines
897 B
Python
33 lines
897 B
Python
"""Provides helper classes for testing option handling in pip
|
|
"""
|
|
|
|
import os
|
|
|
|
from pip._internal.cli import cmdoptions
|
|
from pip._internal.cli.base_command import Command
|
|
from pip._internal.commands import CommandInfo, commands_dict
|
|
from tests.lib.configuration_helpers import reset_os_environ
|
|
|
|
|
|
class FakeCommand(Command):
|
|
|
|
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['fake'] = CommandInfo(
|
|
'tests.lib.options_helpers', 'FakeCommand', 'fake summary',
|
|
)
|
|
|
|
def teardown(self):
|
|
reset_os_environ(self.environ_before)
|
|
commands_dict.pop('fake')
|