|
| 1 | +import json |
1 | 2 | import os.path
|
2 | 3 | import textwrap
|
3 | 4 |
|
@@ -106,6 +107,37 @@ def test_multiple_requirements_files(script, tmpdir):
|
106 | 107 | assert script.venv / 'src' / 'initools' in result.files_created
|
107 | 108 |
|
108 | 109 |
|
| 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 | + |
109 | 141 | def test_respect_order_in_requirements_file(script, data):
|
110 | 142 | script.scratch_path.join("frameworks-req.txt").write(textwrap.dedent("""\
|
111 | 143 | parent
|
|
0 commit comments