try to fix progess bar test in a parallel pytest environment

This commit is contained in:
Ivan Shcheklein
2019-03-17 19:33:09 -07:00
parent 75421f0f21
commit f085e01717
2 changed files with 10 additions and 1 deletions
+6
View File
@@ -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
+4 -1
View File
@@ -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()