|
3 | 3 | import pytest
|
4 | 4 |
|
5 | 5 | from pipenv.utils.shell import temp_environ
|
6 |
| - |
| 6 | +from pipenv.routines.requirements import requirements_from_deps |
7 | 7 |
|
8 | 8 | @pytest.mark.requirements
|
9 | 9 | def test_requirements_generates_requirements_from_lockfile(pipenv_instance_pypi):
|
@@ -192,6 +192,7 @@ def test_requirements_markers_get_excluded(pipenv_instance_pypi):
|
192 | 192 | assert c.returncode == 0
|
193 | 193 | assert markers not in c.stdout
|
194 | 194 |
|
| 195 | + |
195 | 196 | @pytest.mark.requirements
|
196 | 197 | def test_requirements_hashes_get_included(pipenv_instance_pypi):
|
197 | 198 | package, version, markers = "werkzeug", "==2.1.2", "python_version >= '3.7'"
|
@@ -220,6 +221,7 @@ def test_requirements_hashes_get_included(pipenv_instance_pypi):
|
220 | 221 | assert c.returncode == 0
|
221 | 222 | assert f'{package}{version}; {markers} --hash={first_hash} --hash={second_hash}' in c.stdout
|
222 | 223 |
|
| 224 | + |
223 | 225 | def test_requirements_generates_requirements_from_lockfile_without_env_var_expansion(
|
224 | 226 | pipenv_instance_pypi,
|
225 | 227 | ):
|
@@ -250,3 +252,48 @@ def test_requirements_generates_requirements_from_lockfile_without_env_var_expan
|
250 | 252 | "-i https://${redacted_user}:${redacted_pwd}@private_source.org"
|
251 | 253 | in c.stdout
|
252 | 254 | )
|
| 255 | + |
| 256 | + |
| 257 | +@pytest.mark.requirements |
| 258 | +@pytest.mark.parametrize( |
| 259 | + "deps, include_hashes, include_markers, expected", |
| 260 | + [ |
| 261 | + ( |
| 262 | + { |
| 263 | + "django-storages": { |
| 264 | + "version": "==1.12.3", |
| 265 | + "extras": ["azure"] |
| 266 | + } |
| 267 | + }, |
| 268 | + True, |
| 269 | + True, |
| 270 | + ["django-storages[azure]==1.12.3"] |
| 271 | + ), |
| 272 | + ( |
| 273 | + { |
| 274 | + "evotum-cripto": { |
| 275 | + "file": "https://gitlab.com/eVotUM/Cripto-py/-/archive/develop/Cripto-py-develop.zip" |
| 276 | + } |
| 277 | + }, |
| 278 | + True, |
| 279 | + True, |
| 280 | + ["https://gitlab.com/eVotUM/Cripto-py/-/archive/develop/Cripto-py-develop.zip"] |
| 281 | + ), |
| 282 | + ( |
| 283 | + { |
| 284 | + "pyjwt": { |
| 285 | + "git": "https://github.com/jpadilla/pyjwt.git", |
| 286 | + "ref": "7665aa625506a11bae50b56d3e04413a3dc6fdf8", |
| 287 | + "extras": ["crypto"] |
| 288 | + } |
| 289 | + }, |
| 290 | + True, |
| 291 | + True, |
| 292 | + ["pyjwt[crypto] @ git+https://github.com/jpadilla/pyjwt.git@7665aa625506a11bae50b56d3e04413a3dc6fdf8"] |
| 293 | + ) |
| 294 | + ] |
| 295 | +) |
| 296 | +def test_requirements_from_deps(deps, include_hashes, include_markers, expected): |
| 297 | + result = requirements_from_deps(deps, include_hashes, include_markers) |
| 298 | + assert result == expected |
| 299 | + |
0 commit comments