Skip to content

Commit

Permalink
disabled pytest capturing for the captured_out filter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwlouse committed Jan 5, 2017
1 parent 0f7965e commit fb79e00
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
11 changes: 6 additions & 5 deletions tests/test_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys

from sacred.experiment import Experiment
from sacred.utils import apply_backspaces_and_linefeeds


@pytest.fixture
Expand Down Expand Up @@ -163,10 +164,7 @@ def run(a):
assert ex.run(named_configs=['ncfg']).result == 10


def test_captured_out_filter(ex):
from sacred.utils import apply_backspaces_and_linefeeds
ex.captured_out_filter = apply_backspaces_and_linefeeds

def test_captured_out_filter(ex, capsys):
@ex.main
def run_print_mock_progress():
sys.stdout.write('progress 0')
Expand All @@ -176,7 +174,10 @@ def run_print_mock_progress():
sys.stdout.write(str(i))
sys.stdout.flush()

assert ex.run(options={'--loglevel': 'ERROR'}).captured_out == 'progress 9'
ex.captured_out_filter = apply_backspaces_and_linefeeds
options = {'--loglevel': 'CRITICAL'} # to disable logging
with capsys.disabled():
assert ex.run(options=options).captured_out == 'progress 9'


def test_adding_option_hooks(ex):
Expand Down
12 changes: 7 additions & 5 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

from sacred.run import Run
from sacred.config.config_summary import ConfigSummary
from sacred.utils import ObserverError, SacredInterrupt, TimeoutInterrupt
from sacred.utils import (ObserverError, SacredInterrupt, TimeoutInterrupt,
apply_backspaces_and_linefeeds)


@pytest.fixture
Expand Down Expand Up @@ -224,16 +225,17 @@ def test_unobserved_run_doesnt_emit(run):
assert not observer.failed_event.called


def test_captured_out_filter(run):
from sacred.utils import apply_backspaces_and_linefeeds
def test_captured_out_filter(run, capsys):
def print_mock_progress():
sys.stdout.write('progress 0')
sys.stdout.flush()
for i in range(10):
sys.stdout.write('\b')
sys.stdout.write(str(i))
sys.stdout.flush()

run.captured_out_filter = apply_backspaces_and_linefeeds
run.main_function.side_effect = print_mock_progress
run()
assert run.captured_out == 'progress 9'
with capsys.disabled():
run()
assert run.captured_out == 'progress 9'

0 comments on commit fb79e00

Please sign in to comment.