Skip to content

Commit af4ce8a

Browse files
committed
Remove misleading test cases and improve docs
1 parent 0882aff commit af4ce8a

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

docs/reference/pip_install.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,17 @@ script as:
116116

117117
python setup.py --no-user-cfg install --prefix='/usr/local' --no-compile
118118

119-
Note that the correct way of giving more than one option to
120-
``setup.py`` is through multiple ``--global-option`` and
121-
``--install-option`` options, as shown in the example above.
119+
Note that the only way of giving more than one option to ``setup.py``
120+
is through multiple ``--global-option`` and ``--install-option``
121+
options, as shown in the example above. The value of each option is
122+
passed as a single argument to the ``setup.py`` script. Therefore, a
123+
line such as the following is invalid and would result in an
124+
installation error.
125+
126+
::
127+
128+
# Invalid. Please use '--install-option' twice as shown above.
129+
FooProject >= 1.2 --install-option="--prefix=/usr/local --no-compile"
122130

123131

124132
.. _`Pre Release Versions`:

tests/functional/test_install_reqs.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,18 @@ def getsetuppyargs(contents):
127127
return json.load(open(setuppyargs_file))
128128

129129
reqfile = '''
130-
setuppyargs==1.0 --global-option="--one --two" \\
131-
--global-option="--three" \\
132-
--install-option "--four -5" \\
133-
--install-option="-6"
130+
setuppyargs==1.0 --global-option="--onetwo" \\
131+
--global-option="--three" \\
132+
--install-option "--four-5" \\
133+
--install-option="-6" \\
134+
--install-option="--opt-with-ws=a b c"
134135
'''
135136

136137
args = getsetuppyargs(reqfile)
137-
expected = set(['--one --two', '--three', '--four -5', '-6'])
138+
expected = set([
139+
'--onetwo', '--three',
140+
'--four-5', '-6', '--opt-with-ws=a b c'
141+
])
138142
assert expected.issubset(set(args))
139143

140144

tests/unit/test_req.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -554,29 +554,31 @@ def test_parse_flags_from_requirements(finder):
554554

555555

556556
def test_get_requirement_options():
557-
res = parse_requirement_options('--install-option="--abc --zxc"')
558-
assert res == {'install_options': ['--abc --zxc']}
559-
560557
res = parse_requirement_options('--global-option "--abc"')
561558
assert res == {'global_options': ['--abc']}
562559

560+
# Note the '--arg-with-spaces=a b c' is passed as a single
561+
# argument to setup.py.
562+
res = parse_requirement_options('--install-option="--opt-spaces=a b c"')
563+
assert res == {'install_options': ['--opt-spaces=a b c']}
564+
563565
line = (
564566
'INITools==2.0 '
565-
'--global-option="--one --two -3" '
567+
'--global-option="--one --two=3 3.5" '
566568
'--global-option="--four" '
567569
'--install-option="--prefix=/opt" '
568570
'--install-option="--help" '
569571
)
570572
assert parse_line(line) == (REQUIREMENT, (
571573
'INITools==2.0', {
572-
'global_options': ['--one --two -3', '--four'],
574+
'global_options': ['--one --two=3 3.5', '--four'],
573575
'install_options': ['--prefix=/opt', '--help'],
574576
}))
575577

576578

577579
def test_install_requirements_with_options(tmpdir, finder, session):
578580
content = '''
579-
INITools == 2.0 --global-option="--one --two -3" \
581+
INITools == 2.0 --global-option="--one-two-3" \
580582
--install-option "--prefix=/opt"
581583
'''
582584

@@ -594,7 +596,7 @@ def test_install_requirements_with_options(tmpdir, finder, session):
594596
pass
595597

596598
call = popen.call_args_list[0][0][0]
597-
for i in '--one --two -3', '--prefix=/opt':
599+
for i in '--one-two-3', '--prefix=/opt':
598600
assert i in call
599601

600602
# TODO: assert that --global-option come before --install-option.

0 commit comments

Comments
 (0)