X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=unittest_utils.py;h=b259c6b4c98f687d8e3c8db4b41c280db7ac9d19;hb=ffed473528c4feb836253758e86f7839af98f57b;hp=81b339ae3485d05e6f76248aa8fbeb70f52ef2a3;hpb=5317c50ce7a96a37acfab3800c0935580766dbbf;p=python_utils.git diff --git a/unittest_utils.py b/unittest_utils.py index 81b339a..b259c6b 100644 --- a/unittest_utils.py +++ b/unittest_utils.py @@ -7,7 +7,6 @@ caveat emptor. """ -from abc import ABC, abstractmethod import contextlib import functools import inspect @@ -16,20 +15,20 @@ import os import pickle import random import statistics -import time import tempfile -from typing import Any, Callable, Dict, List, Optional +import time import unittest import warnings +from abc import ABC, abstractmethod +from typing import Any, Callable, Dict, List, Optional + +import sqlalchemy as sa import bootstrap import config import function_utils import scott_secrets -import sqlalchemy as sa - - logger = logging.getLogger(__name__) cfg = config.add_commandline_args( f'Logging ({__file__})', 'Args related to function decorators' @@ -287,12 +286,12 @@ class RecordStdout(object): def __enter__(self) -> Callable[[], tempfile.SpooledTemporaryFile]: self.recorder = contextlib.redirect_stdout(self.destination) - assert self.recorder + assert self.recorder is not None self.recorder.__enter__() return lambda: self.destination def __exit__(self, *args) -> Optional[bool]: - assert self.recorder + assert self.recorder is not None self.recorder.__exit__(*args) self.destination.seek(0) return None @@ -316,12 +315,12 @@ class RecordStderr(object): def __enter__(self) -> Callable[[], tempfile.SpooledTemporaryFile]: self.recorder = contextlib.redirect_stderr(self.destination) # type: ignore - assert self.recorder + assert self.recorder is not None self.recorder.__enter__() return lambda: self.destination def __exit__(self, *args) -> Optional[bool]: - assert self.recorder + assert self.recorder is not None self.recorder.__exit__(*args) self.destination.seek(0) return None