Skip to content
Merged
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
25 changes: 9 additions & 16 deletions diffsims/tests/generators/test_simulation_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import numpy as np
import pytest
from pathlib import Path
import re

import diffpy.structure
from orix.crystal_map import Phase
Expand Down Expand Up @@ -359,10 +360,9 @@ def test_calculate_diffraction2d_progressbar_single_phase(capsys):
sims = gen.calculate_diffraction2d(phase, rots, show_progressbar=True)

captured = capsys.readouterr()
expected = "test phase: 100%|██████████| 10/10" # also some more, but that is compute-time dependent
# ignore possible flushing
captured = captured.err.split("\r")[-1]
assert "████" in captured # This can be faulty on CI, but we check for the bar
# Accept any number of "█" characters
expected = "test phase: 100\%\|█+\| 10\/10"
assert re.findall(expected, captured.err)


def test_calculate_diffraction2d_progressbar_multi_phase(capsys):
Expand All @@ -388,15 +388,8 @@ def test_calculate_diffraction2d_progressbar_multi_phase(capsys):
)

captured = capsys.readouterr()
expected1 = "A: 100%|██████████| 10/10 "
expected2 = "B: 100%|██████████| 10/10 "
# Find the correct output in the stream, i.e. final line containing the name of the phase
captured1 = ""
captured2 = ""
for line in captured.err.split("\r"):
if "A" in line:
captured1 = line
if "B" in line:
captured2 = line
assert "██" in captured1 # This can be faulty on CI
assert "██" in captured2 # Just make sure there is some progress bar
# Accept any number of "█" characters
expected1 = "A: 100\%\|█+\| 10\/10 "
expected2 = "B: 100\%\|█+\| 10\/10 "
assert re.findall(expected1, captured.err)
assert re.findall(expected2, captured.err)
Loading