Skip to content

Commit

Permalink
azure-job.yml: Use python -u
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed Sep 8, 2019
1 parent a7762f1 commit f3ec6f9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion azure-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ jobs:
- script: pip install -r requirements-ci.txt
displayName: Install CI requirements

- script: PYTHONUNBUFFERED=1 pytest
- script: python -u -m pytest
displayName: Run pytest (Python ${{ python.value.spec }})
19 changes: 18 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@
from stdio_mgr import stdio_mgr


# is_stdout_buffered is copied from https://stackoverflow.com/a/49736559
# Licensed CC-BY-SA 4.0
# Author https://stackoverflow.com/users/528711/sparrowt
def is_stdout_buffered():
# Print a single space + carriage return but no new-line
# (should have no visible effect)
print(" \r")
# If the file position is a positive integer then stdout is buffered
try:
pos = sys.stdout.tell()
if pos > 0:
return True
except IOError: # In some terminals tell() throws IOError if stdout is unbuffered
pass
return False


@pytest.fixture(scope="session")
def warnings_are_errors(pytestconfig):
"""Provide concise access to '-W error::Warning' CLI option."""
Expand Down Expand Up @@ -76,7 +93,7 @@ def enable_warnings_plugin(request):
@pytest.fixture(scope="session")
def unbufferedio():
"""Provide concise access to PYTHONUNBUFFERED envvar."""
return os.environ.get("PYTHONUNBUFFERED")
return os.environ.get("PYTHONUNBUFFERED") or not is_stdout_buffered()


@pytest.fixture(autouse=True)
Expand Down

0 comments on commit f3ec6f9

Please sign in to comment.