Repository: python-poetry/poetry

Issue:
Exported requirements.txt contains spurious error message, making it unparseable
- [X] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) Poetry version.
- [X] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate.
- [X] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).

- **OS version and name**: macOS 10.15.7
- **Poetry version**: 1.1.6
- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: Too much internal stuff to share, it's not really related, though

## Issue

When I run `poetry export > requirements.txt && pip install -r requirements.txt`, I see this:

```
 Invalid requirement: 'Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.' (from line 1 of requirements.txt)
```

It appears that my Poetry lockfile is out of sync. No biggie, that's correctable and logged in #3092 when it's not necessary to resync.

However, this error message should not make it into the output of the `poetry export` command. That error log line should go to stderr, not stdout.

## Proposed Fix

I think that the `self.line` here https://github.com/python-poetry/poetry/blob/b753aaf4c3c08ef0e54941a6616fe318fdf4f6e4/poetry/console/commands/export.py#L56-L63
should be `self.line_error` which, according to the [docstring for that method](https://github.com/sdispater/cleo/blob/9d289bf709ab2119b58e95da58a655ab70661798/cleo/commands/command.py#L262-L276) outputs to stderr instead of stdout.


Discussion:

Resolving patch:
diff --git a/poetry/console/commands/export.py b/poetry/console/commands/export.py
--- a/poetry/console/commands/export.py
+++ b/poetry/console/commands/export.py
@@ -41,7 +41,7 @@ def handle(self) -> None:
 
         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 @@ def handle(self) -> None:
             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. "


Test patch:
diff --git a/tests/console/commands/test_export.py b/tests/console/commands/test_export.py
--- a/tests/console/commands/test_export.py
+++ b/tests/console/commands/test_export.py
@@ -77,12 +77,12 @@ def _export_requirements(tester, poetry):
 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):