mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
try to fix progess bar test in a parallel pytest environment
This commit is contained in:
@@ -38,6 +38,12 @@ class Progress(object):
|
||||
self._print(line, end="")
|
||||
sys.stdout.flush()
|
||||
|
||||
def reset(self):
|
||||
with self._lock:
|
||||
self._n_total = 0
|
||||
self._n_finished = 0
|
||||
self._line = None
|
||||
|
||||
def refresh(self, line=None):
|
||||
"""Refreshes progress bar."""
|
||||
# Just go away if it is locked. Will update next time
|
||||
|
||||
@@ -7,7 +7,10 @@ from dvc.progress import progress, progress_aware
|
||||
class TestProgressAware(TestCase):
|
||||
@mock.patch("sys.stdout.isatty", return_value=True)
|
||||
@mock.patch("dvc.progress.Progress._print")
|
||||
def test(self, mock_print, mock_isatty):
|
||||
def test(self, mock_print, _):
|
||||
# progress is a global object, can be shared between tests when
|
||||
# run in multi-threading environment with pytest
|
||||
progress.reset()
|
||||
function = progress_aware(lambda: None)
|
||||
|
||||
function()
|
||||
|
||||
Reference in New Issue
Block a user