1919import numpy as np
2020import pytest
2121from pathlib import Path
22+ import re
2223
2324import diffpy .structure
2425from orix .crystal_map import Phase
@@ -359,10 +360,9 @@ def test_calculate_diffraction2d_progressbar_single_phase(capsys):
359360 sims = gen .calculate_diffraction2d (phase , rots , show_progressbar = True )
360361
361362 captured = capsys .readouterr ()
362- expected = "test phase: 100%|██████████| 10/10" # also some more, but that is compute-time dependent
363- # ignore possible flushing
364- captured = captured .err .split ("\r " )[- 1 ]
365- assert "████" in captured # This can be faulty on CI, but we check for the bar
363+ # Accept any number of "█" characters
364+ expected = "test phase: 100\%\|█+\| 10\/10"
365+ assert re .findall (expected , captured .err )
366366
367367
368368def test_calculate_diffraction2d_progressbar_multi_phase (capsys ):
@@ -388,15 +388,8 @@ def test_calculate_diffraction2d_progressbar_multi_phase(capsys):
388388 )
389389
390390 captured = capsys .readouterr ()
391- expected1 = "A: 100%|██████████| 10/10 "
392- expected2 = "B: 100%|██████████| 10/10 "
393- # Find the correct output in the stream, i.e. final line containing the name of the phase
394- captured1 = ""
395- captured2 = ""
396- for line in captured .err .split ("\r " ):
397- if "A" in line :
398- captured1 = line
399- if "B" in line :
400- captured2 = line
401- assert "██" in captured1 # This can be faulty on CI
402- assert "██" in captured2 # Just make sure there is some progress bar
391+ # Accept any number of "█" characters
392+ expected1 = "A: 100\%\|█+\| 10\/10 "
393+ expected2 = "B: 100\%\|█+\| 10\/10 "
394+ assert re .findall (expected1 , captured .err )
395+ assert re .findall (expected2 , captured .err )
0 commit comments