Disallow where're too.
[python_utils.git] / unittest_utils.py
index 81b339ae3485d05e6f76248aa8fbeb70f52ef2a3..b259c6b4c98f687d8e3c8db4b41c280db7ac9d19 100644 (file)
@@ -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