From 0da51b14d75947d23bb620ca57eb4d1a06b8a37b Mon Sep 17 00:00:00 2001 From: Georgi Valkov Date: Tue, 24 Mar 2015 11:31:36 +0100 Subject: [PATCH] Remove misleading test cases and improve docs --- docs/reference/pip_install.rst | 14 +++++++++++--- tests/functional/test_install_reqs.py | 14 +++++++++----- tests/unit/test_req.py | 16 +++++++++------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/docs/reference/pip_install.rst b/docs/reference/pip_install.rst index 35b39faba..5f11cba73 100644 --- a/docs/reference/pip_install.rst +++ b/docs/reference/pip_install.rst @@ -165,9 +165,17 @@ script as: python setup.py --no-user-cfg install --prefix='/usr/local' --no-compile -Note that the correct way of giving more than one option to -``setup.py`` is through multiple ``--global-option`` and -``--install-option`` options, as shown in the example above. +Note that the only way of giving more than one option to ``setup.py`` +is through multiple ``--global-option`` and ``--install-option`` +options, as shown in the example above. The value of each option is +passed as a single argument to the ``setup.py`` script. Therefore, a +line such as the following is invalid and would result in an +installation error. + +:: + + # Invalid. Please use '--install-option' twice as shown above. + FooProject >= 1.2 --install-option="--prefix=/usr/local --no-compile" .. _`Pre Release Versions`: diff --git a/tests/functional/test_install_reqs.py b/tests/functional/test_install_reqs.py index 2cb7159bf..276d57c7c 100644 --- a/tests/functional/test_install_reqs.py +++ b/tests/functional/test_install_reqs.py @@ -127,14 +127,18 @@ def test_requirement_file_options(script, data, tmpdir): return json.load(open(setuppyargs_file)) reqfile = ''' - setuppyargs==1.0 --global-option="--one --two" \\ - --global-option="--three" \\ - --install-option "--four -5" \\ - --install-option="-6" + setuppyargs==1.0 --global-option="--onetwo" \\ + --global-option="--three" \\ + --install-option "--four-5" \\ + --install-option="-6" \\ + --install-option="--opt-with-ws=a b c" ''' args = getsetuppyargs(reqfile) - expected = set(['--one --two', '--three', '--four -5', '-6']) + expected = set([ + '--onetwo', '--three', + '--four-5', '-6', '--opt-with-ws=a b c' + ]) assert expected.issubset(set(args)) diff --git a/tests/unit/test_req.py b/tests/unit/test_req.py index 1b7976e69..abfe99de4 100644 --- a/tests/unit/test_req.py +++ b/tests/unit/test_req.py @@ -511,29 +511,31 @@ def test_parse_flags_from_requirements(finder): def test_get_requirement_options(): - res = parse_requirement_options('--install-option="--abc --zxc"') - assert res == {'install_options': ['--abc --zxc']} - res = parse_requirement_options('--global-option "--abc"') assert res == {'global_options': ['--abc']} + # Note the '--arg-with-spaces=a b c' is passed as a single + # argument to setup.py. + res = parse_requirement_options('--install-option="--opt-spaces=a b c"') + assert res == {'install_options': ['--opt-spaces=a b c']} + line = ( 'INITools==2.0 ' - '--global-option="--one --two -3" ' + '--global-option="--one --two=3 3.5" ' '--global-option="--four" ' '--install-option="--prefix=/opt" ' '--install-option="--help" ' ) assert parse_line(line) == (REQUIREMENT, ( 'INITools==2.0', { - 'global_options': ['--one --two -3', '--four'], + 'global_options': ['--one --two=3 3.5', '--four'], 'install_options': ['--prefix=/opt', '--help'], })) def test_install_requirements_with_options(tmpdir, finder, session): content = ''' - INITools == 2.0 --global-option="--one --two -3" \ + INITools == 2.0 --global-option="--one-two-3" \ --install-option "--prefix=/opt" ''' @@ -551,7 +553,7 @@ def test_install_requirements_with_options(tmpdir, finder, session): pass call = popen.call_args_list[0][0][0] - for i in '--one --two -3', '--prefix=/opt': + for i in '--one-two-3', '--prefix=/opt': assert i in call # TODO: assert that --global-option come before --install-option.