Skip to content

Commit

Permalink
Merge pull request #35 from elchupanebrej/clean_up
Browse files Browse the repository at this point in the history
Cleanup library env
  • Loading branch information
Dmitrii Misharov authored Jul 19, 2021
2 parents a78771a + a0c67dd commit c5a7f22
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand Down
10 changes: 8 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[metadata]
name = wait_for
author = Peter Savage
author-email = [email protected]
author_email = [email protected]
summary = A waiting based utility with decorator and logger support
description-file = README.rst
url = https://github.com/RedHatQE/wait_for
Expand All @@ -12,10 +12,10 @@ classifier =
Intended Audience :: Developers
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Utilities
keywords =
setup
Expand All @@ -25,6 +25,12 @@ keywords =
install_requires =
parsedatetime>=2.5

tests_require =
pytest

python_requires=
>=3.6

[files]
packages =
wait_for
Expand Down
1 change: 0 additions & 1 deletion tests/test_exception.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest

from wait_for import wait_for, TimedOutError
Expand Down
2 changes: 0 additions & 2 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# pylint: disable=W0621
from unittest.mock import patch
import pytest
import time
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[tox]
envlist = py{36,37,38},codechecks
envlist = py{36,37,38,39},codechecks

[testenv]
usedevelop = true
deps=
pytest
pytest-cov
coveralls
mock
commands = py.test {posargs: tests/ -v --cov wait_for}

[testenv:codechecks]
Expand All @@ -24,4 +23,5 @@ python =
3.6: py36,codechecks
3.7: py37,codechecks
3.8: py38,codechecks
3.9: py39,codechecks

16 changes: 6 additions & 10 deletions wait_for/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
import time
import inspect
import logging
import time
from collections import namedtuple
from datetime import datetime, timedelta
from functools import partial
from threading import Timer
from types import LambdaType
import inspect

import parsedatetime

Expand All @@ -18,9 +17,6 @@
default_hidden_logger.propagate = False
default_hidden_logger.addHandler(logging.NullHandler())

# Available in 3.3+
get_time = time.monotonic


def _parse_time(t):
global calendar
Expand Down Expand Up @@ -143,7 +139,7 @@ def wait_for(func, func_args=[], func_kwargs={}, logger=None, **kwargs):
# https://docs.pytest.org/en/latest/example/simple.html#writing-well-integrated-assertion-helpers
__tracebackhide__ = True
logger = logger or default_hidden_logger
st_time = get_time()
st_time = time.monotonic()
total_time = 0

num_sec = _get_timeout_secs(kwargs)
Expand Down Expand Up @@ -187,7 +183,7 @@ def wait_for(func, func_args=[], func_kwargs={}, logger=None, **kwargs):
logger.info(
"%(message)r took %(tries)d tries and %(time).2f seconds "
"before failure from an exception.",
{'message': message, 'tries': tries, 'time': get_time() - st_time})
{'message': message, 'tries': tries, 'time': time.monotonic() - st_time})
raise
if out is fail_condition or fail_condition_check(out):
time.sleep(delay)
Expand All @@ -197,7 +193,7 @@ def wait_for(func, func_args=[], func_kwargs={}, logger=None, **kwargs):
if fail_func:
fail_func()
else:
duration = get_time() - st_time
duration = time.monotonic() - st_time
if not quiet:
logger.debug(
"Took %(time).2f to do %(message)r",
Expand All @@ -207,7 +203,7 @@ def wait_for(func, func_args=[], func_kwargs={}, logger=None, **kwargs):
"Finished %(message)r at %(duration).2f, %(tries)d tries",
{'message': message, 'duration': st_time + t_delta, 'tries': tries})
return WaitForResult(out, duration)
t_delta = get_time() - st_time
t_delta = time.monotonic() - st_time
if not very_quiet:
logger.debug(
"Finished %(message)r at %(duration).2f",
Expand Down

0 comments on commit c5a7f22

Please sign in to comment.