|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +import shutil |
| 4 | + |
3 | 5 | from typing import TYPE_CHECKING |
4 | 6 | from unittest.mock import Mock |
5 | 7 |
|
@@ -229,3 +231,44 @@ def test_export_with_urls( |
229 | 231 | monkeypatch.setattr(Exporter, "with_urls", mock_export) |
230 | 232 | tester.execute("--without-urls") |
231 | 233 | mock_export.assert_called_once_with(False) |
| 234 | + |
| 235 | + |
| 236 | +def test_export_exports_constraints_txt_with_warnings( |
| 237 | + tmp_path: Path, |
| 238 | + fixture_root: Path, |
| 239 | + project_factory: ProjectFactory, |
| 240 | + command_tester_factory: CommandTesterFactory, |
| 241 | +) -> None: |
| 242 | + # On Windows we have to make sure that the path dependency and the pyproject.toml |
| 243 | + # are on the same drive, otherwise locking fails. |
| 244 | + # (in our CI fixture_root is on D:\ but temp_path is on C:\) |
| 245 | + editable_dep_path = tmp_path / "project_with_nested_local" |
| 246 | + shutil.copytree(fixture_root / "project_with_nested_local", editable_dep_path) |
| 247 | + |
| 248 | + pyproject_content = f"""\ |
| 249 | +[tool.poetry] |
| 250 | +name = "simple-project" |
| 251 | +version = "1.2.3" |
| 252 | +description = "Some description." |
| 253 | +authors = [ |
| 254 | + "Sébastien Eustace <[email protected]>" |
| 255 | +] |
| 256 | +
|
| 257 | +[tool.poetry.dependencies] |
| 258 | +python = "^3.6" |
| 259 | +baz = ">1.0" |
| 260 | +project-with-nested-local = {{ path = "{editable_dep_path.as_posix()}", \ |
| 261 | +develop = true }} |
| 262 | +""" |
| 263 | + poetry = project_factory(name="export", pyproject_content=pyproject_content) |
| 264 | + tester = command_tester_factory("export", poetry=poetry) |
| 265 | + tester.execute("--format constraints.txt") |
| 266 | + |
| 267 | + develop_warning = ( |
| 268 | + "Warning: project-with-nested-local is locked in develop (editable) mode, which" |
| 269 | + " is incompatible with the constraints.txt format.\n" |
| 270 | + ) |
| 271 | + expected = 'baz==2.0.0 ; python_version >= "3.6" and python_version < "4.0"\n' |
| 272 | + |
| 273 | + assert develop_warning in tester.io.fetch_error() |
| 274 | + assert tester.io.fetch_output() == expected |
0 commit comments