Skip to content

Commit

Permalink
Direct logging to dev/null instead of stdout in tests to make test ou…
Browse files Browse the repository at this point in the history
…tput clearer
  • Loading branch information
benvand committed Sep 10, 2018
1 parent d8e4490 commit 374b492
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import mock
import os
import pytest

from flask import Flask
Expand All @@ -10,6 +11,17 @@
from dmutils.logging import init_app


@pytest.fixture(scope='session', autouse=True)
def direct_stdout_to_null():
"""Redirect logging to dev/null in tests only. Otherwise logger is set to stdout by default for dev envs.
See digitalmarketplace-utils/dmutils/logging.py::get_handler
"""
with open(os.devnull, 'w') as null:
with mock.patch('dmutils.logging.sys.stdout', null):
yield


@pytest.fixture
def app(request):
app = Flask(__name__)
Expand Down

0 comments on commit 374b492

Please sign in to comment.