1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00
pip/tests/unit/test_cmdoptions.py
Anthony Sottile e21e2d3f8f Upgrade syntax in ./tests
Changes were automated via https://github.com/asottile/pyupgrade

See #4921
2017-12-14 21:59:41 -08:00

52 lines
1.5 KiB
Python

from pip._internal import cmdoptions, index
from pip._internal.basecommand import Command
class SimpleCommand(Command):
name = 'fake'
summary = name
def __init__(self):
super(SimpleCommand, self).__init__()
self.cmd_opts.add_option(cmdoptions.no_binary())
self.cmd_opts.add_option(cmdoptions.only_binary())
def run(self, options, args):
self.options = options
def test_no_binary_overrides():
cmd = SimpleCommand()
cmd.main(['fake', '--only-binary=:all:', '--no-binary=fred'])
expected = index.FormatControl({'fred'}, {':all:'})
assert cmd.options.format_control == expected
def test_only_binary_overrides():
cmd = SimpleCommand()
cmd.main(['fake', '--no-binary=:all:', '--only-binary=fred'])
expected = index.FormatControl({':all:'}, {'fred'})
assert cmd.options.format_control == expected
def test_none_resets():
cmd = SimpleCommand()
cmd.main(['fake', '--no-binary=:all:', '--no-binary=:none:'])
expected = index.FormatControl(set(), set())
assert cmd.options.format_control == expected
def test_none_preserves_other_side():
cmd = SimpleCommand()
cmd.main(
['fake', '--no-binary=:all:', '--only-binary=fred',
'--no-binary=:none:'])
expected = index.FormatControl(set(), {'fred'})
assert cmd.options.format_control == expected
def test_comma_separated_values():
cmd = SimpleCommand()
cmd.main(['fake', '--no-binary=1,2,3'])
expected = index.FormatControl({'1', '2', '3'}, set())
assert cmd.options.format_control == expected