Commit c3209550 by Colin Dean Committed by GitHub

Emit export errors to stderr to prevent invalid output (#4110)

* Emit export errors to stderr to prevent invalid output

An error in export could emit error messages to stdout, causing the requirements.txt output to stdout to be invalid.

Fixes #4109

* Looks at stderr for export tests
parent e180aab1
......@@ -41,7 +41,7 @@ class ExportCommand(Command):
locker = self.poetry.locker
if not locker.is_locked():
self.line("<comment>The lock file does not exist. Locking.</comment>")
self.line_error("<comment>The lock file does not exist. Locking.</comment>")
options = []
if self.io.is_debug():
options.append(("-vvv", None))
......@@ -53,7 +53,7 @@ class ExportCommand(Command):
self.call("lock", " ".join(options))
if not locker.is_fresh():
self.line(
self.line_error(
"<warning>"
"Warning: The lock file is not up to date with "
"the latest changes in pyproject.toml. "
......
......@@ -77,12 +77,12 @@ foo==1.0.0
def test_export_exports_requirements_txt_file_locks_if_no_lock_file(tester, poetry):
assert not poetry.locker.lock.exists()
_export_requirements(tester, poetry)
assert "The lock file does not exist. Locking." in tester.io.fetch_output()
assert "The lock file does not exist. Locking." in tester.io.fetch_error()
def test_export_exports_requirements_txt_uses_lock_file(tester, poetry, do_lock):
_export_requirements(tester, poetry)
assert "The lock file does not exist. Locking." not in tester.io.fetch_output()
assert "The lock file does not exist. Locking." not in tester.io.fetch_error()
def test_export_fails_on_invalid_format(tester, do_lock):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment