monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f94ac53cc18>
def test_clone_timeout(monkeypatch):
src = "https://www.mercurial-scm.org/repo/hello"
dest = "/dev/null"
timeout = 1
def clone(*args):
time.sleep(5)
monkeypatch.setattr(hg, "clone", clone)
with pytest.raises(hgutil.CloneTimeout) as e:
> hgutil.clone(src, dest, timeout)
.tox/py3/lib/python3.7/site-packages/swh/loader/mercurial/tests/test_hgutil.py:26:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src = 'https://www.mercurial-scm.org/repo/hello', dest = '/dev/null'
timeout = 1
def clone(src: str, dest: str, timeout: int) -> None:
"""Clone a repository with timeout.
Args:
src: clone source
dest: clone destination
timeout: timeout in seconds
"""
errors: Queue = Queue()
process = Process(target=_clone_task, args=(src, dest, errors))
process.start()
process.join(timeout)
if process.is_alive():
process.terminate()
process.join(1)
if process.is_alive():
process.kill()
raise CloneTimeout(src, timeout)
if not errors.empty():
> raise CloneFailure(src, dest, errors.get())
E swh.loader.mercurial.hgutil.CloneFailure: ('https://www.mercurial-scm.org/repo/hello', '/dev/null', 'Traceback (most recent call last):\n File "/var/lib/jenkins/workspace/DLDHG/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/loader/mercurial/hgutil.py", line 54, in _clone_task\n update=False,\nTypeError: clone() got an unexpected keyword argument \'ui\'\n')
.tox/py3/lib/python3.7/site-packages/swh/loader/mercurial/hgutil.py:84: CloneFailure
TEST RESULT
TEST RESULT
- Run At
- Feb 25 2021, 12:01 PM