Skip to content

Commit 1924776

Browse files
committed
Add an --install|global-option functional test
1 parent 6e1b768 commit 1924776

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

tests/data/packages/README.txt

+5
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,9 @@ requires_simple_extra-0.1-py2.py3-none-any.whl
9292
----------------------------------------------
9393
requires_simple_extra[extra] requires simple==1.0
9494

95+
setuppyargs-0.1.tar.gz
96+
----------------------
9597

98+
An empty package that will output the arguments with which it's 'setup.py' was
99+
called when installed. If the PIPTEST_SETUPPYARGS_FILE environment variable is
100+
set, the argument list will be written to that file in json format.
801 Bytes
Binary file not shown.

tests/functional/test_install_reqs.py

+32
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os.path
23
import textwrap
34

@@ -106,6 +107,37 @@ def test_multiple_requirements_files(script, tmpdir):
106107
assert script.venv / 'src' / 'initools' in result.files_created
107108

108109

110+
def test_requirement_file_options(script, data, tmpdir):
111+
"""
112+
Test setting --install-option and --global-option in requirements files.
113+
"""
114+
115+
# When the setuppyargs package is installed, it will write the
116+
# arguments with which it's setup.py file was called in
117+
# PIPTEST_SETUPPYARGS_FILE.
118+
setuppyargs_file = tmpdir / 'setup-py-args'
119+
script.environ['PIPTEST_SETUPPYARGS_FILE'] = str(setuppyargs_file)
120+
121+
def getsetuppyargs(contents):
122+
contents = textwrap.dedent(contents)
123+
script.scratch_path.join('reqfileopts.txt').write(contents)
124+
script.pip('install', '--no-index', '-f', data.find_links,
125+
'-r', script.scratch_path / 'reqfileopts.txt',
126+
expect_error=True)
127+
return json.load(open(setuppyargs_file))
128+
129+
reqfile = '''
130+
setuppyargs==1.0 --global-option="--one --two" \\
131+
--global-option="--three" \\
132+
--install-option "--four -5" \\
133+
--install-option="-6"
134+
'''
135+
136+
args = getsetuppyargs(reqfile)
137+
expected = set(['--one', '--two', '--three', '--four', '-5', '-6'])
138+
assert expected.issubset(set(args))
139+
140+
109141
def test_respect_order_in_requirements_file(script, data):
110142
script.scratch_path.join("frameworks-req.txt").write(textwrap.dedent("""\
111143
parent

0 commit comments

Comments
 (0)