mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 02:31:45 +01:00
extend utils.ensure()
This commit is contained in:
@@ -3,9 +3,33 @@ Copyright (C) 2022 Sebastian Thomschke and contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
import os, sys, time
|
||||
import pytest
|
||||
from kleinanzeigen_bot import utils
|
||||
|
||||
|
||||
def test_ensure():
|
||||
utils.ensure(True, "TRUE")
|
||||
utils.ensure("Some Value", "TRUE")
|
||||
utils.ensure(123, "TRUE")
|
||||
utils.ensure(-123, "TRUE")
|
||||
utils.ensure(lambda: True, "TRUE")
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
utils.ensure(False, "FALSE")
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
utils.ensure(0, "FALSE")
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
utils.ensure("", "FALSE")
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
utils.ensure(None, "FALSE")
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
utils.ensure(lambda: False, "FALSE", timeout = 2)
|
||||
|
||||
|
||||
def test_pause():
|
||||
start = time.time()
|
||||
utils.pause(100, 100)
|
||||
@@ -13,4 +37,4 @@ def test_pause():
|
||||
if sys.platform == "darwin" and os.getenv("GITHUB_ACTIONS", "true") == "true":
|
||||
assert 99 < elapsed < 300
|
||||
else:
|
||||
assert 99 < elapsed < 110
|
||||
assert 99 < elapsed < 120
|
||||
|
||||
Reference in New Issue
Block a user