Speed up tests by mocking time.sleep()

This commit is contained in:
Tobias Gruetzmacher 2019-12-03 23:52:14 +01:00
parent d2861d029f
commit fcebd63e66
3 changed files with 20 additions and 0 deletions

17
tests/conftest.py Normal file
View file

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function
import time
import pytest
@pytest.fixture
def nosleep(monkeypatch):
def sleep(seconds):
pass
monkeypatch.setattr(time, 'sleep', sleep)

View file

@ -28,6 +28,7 @@ def cmd_err(*options):
assert cmd(*options) == 1 assert cmd(*options) == 1
@pytest.mark.usefixtures("nosleep")
class TestDosage(object): class TestDosage(object):
"""Test the dosage commandline client.""" """Test the dosage commandline client."""

View file

@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function
import re import re
import pytest
import responses import responses
import dosagelib.cmd import dosagelib.cmd
@ -16,6 +17,7 @@ def cmd(*options):
assert dosagelib.cmd.main(("--allow-multiple",) + options) == 0 assert dosagelib.cmd.main(("--allow-multiple",) + options) == 0
@pytest.mark.usefixtures("nosleep")
class TestModules(object): class TestModules(object):
"""Test that specific comic modules work correctly.""" """Test that specific comic modules work correctly."""