diff --git a/tests/data/packages/README.txt b/tests/data/packages/README.txt index 9e89e9114..9867e043d 100644 --- a/tests/data/packages/README.txt +++ b/tests/data/packages/README.txt @@ -104,4 +104,9 @@ requires_simple_extra-0.1-py2.py3-none-any.whl ---------------------------------------------- requires_simple_extra[extra] requires simple==1.0 +setuppyargs-0.1.tar.gz +---------------------- +An empty package that will output the arguments with which its 'setup.py' was +called when installed. If the PIPTEST_SETUPPYARGS_FILE environment variable is +set, the argument list will be written to that file in json format. diff --git a/tests/data/packages/setuppyargs-1.0.tar.gz b/tests/data/packages/setuppyargs-1.0.tar.gz new file mode 100644 index 000000000..6612ea00e Binary files /dev/null and b/tests/data/packages/setuppyargs-1.0.tar.gz differ diff --git a/tests/functional/test_install_reqs.py b/tests/functional/test_install_reqs.py index 0fe2af414..16772da17 100644 --- a/tests/functional/test_install_reqs.py +++ b/tests/functional/test_install_reqs.py @@ -1,3 +1,4 @@ +import json import os.path import textwrap @@ -106,6 +107,37 @@ def test_multiple_requirements_files(script, tmpdir): assert script.venv / 'src' / 'initools' in result.files_created +def test_requirement_file_options(script, data, tmpdir): + """ + Test setting --install-option and --global-option in requirements files. + """ + + # When the setuppyargs package is installed, it will write the + # arguments with which its setup.py file was called in + # PIPTEST_SETUPPYARGS_FILE. + setuppyargs_file = tmpdir / 'setup-py-args' + script.environ['PIPTEST_SETUPPYARGS_FILE'] = str(setuppyargs_file) + + def getsetuppyargs(contents): + contents = textwrap.dedent(contents) + script.scratch_path.join('reqfileopts.txt').write(contents) + script.pip('install', '--no-index', '-f', data.find_links, + '-r', script.scratch_path / 'reqfileopts.txt', + expect_error=True) + return json.load(open(setuppyargs_file)) + + reqfile = ''' + setuppyargs==1.0 --global-option="--one --two" \\ + --global-option="--three" \\ + --install-option "--four -5" \\ + --install-option="-6" + ''' + + args = getsetuppyargs(reqfile) + expected = set(['--one', '--two', '--three', '--four', '-5', '-6']) + assert expected.issubset(set(args)) + + def test_respect_order_in_requirements_file(script, data): script.scratch_path.join("frameworks-req.txt").write(textwrap.dedent("""\ parent