Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ This option also automatically sets [the standard `NO_COLOR` environment variabl

### How to handle correctly the return lines when my tests are executed on both Windows and non-Windows systems?

Since version 1.4, the `run()` function provides a way to handle it for you. To activate it, set the `normalize_carriage_return` argument to `True`. This might become the default value in a future version.

If you use a previous version, you can reproduce this behavior easily by replacing the `\r\n` characters with `\n` on both `stdout` and `stderr`.
The `run()` function provides a way to handle it for you.
Just set the `normalize_carriage_return` argument to `True`, and any `\r\n` will be replaced with `\n`.
This will become the default behavior in the version 2.0.
12 changes: 11 additions & 1 deletion aurornis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import subprocess
import warnings

from sys import platform
from os import environ
Expand All @@ -17,7 +18,7 @@ def run(
environment: {str: str} = None,
remove_colors: bool = False,
stdin: [str] = None,
normalize_carriage_return: bool = False,
normalize_carriage_return: bool = None,
) -> CommandResult:
"""Execute the given command and return an object ready to check its result.

Expand All @@ -26,6 +27,7 @@ def run(

If you need to run the tests on both UNIX and Windows, it is recommended to set the `normalize_carriage_return` to True.
This way, all the "\r\n" in standard output and standard error will be converted to "\n".
**This will become the default behavior in version 2.0.**

If the command returns a non-zero code, the successful property is false:
>>> c = run(["python3", "-c", r"import sys; print('Oops, it didn\\'t work!', file=sys.stderr); exit(1)"], normalize_carriage_return=True)
Expand Down Expand Up @@ -140,6 +142,14 @@ def _get_execution_environment(
stdout = stdout.decode()
stderr = stderr.decode()

if normalize_carriage_return is None:
normalize_carriage_return = False
warnings.warn(
"The normalize_carriage_return argument of the run() function the will default to True in version 2.0. "
"Set it to False manually to keep the current behavior.",
DeprecationWarning,
)

if normalize_carriage_return:
stdout = stdout.replace("\r\n", "\n")
stderr = stderr.replace("\r\n", "\n")
Expand Down