Let's be explicit with asserts; there was a bug in histogram
[python_utils.git] / unittest_utils.py
index ba9ca28f091bc70bd232cb6f059116cfc70d7fb9..b259c6b4c98f687d8e3c8db4b41c280db7ac9d19 100644 (file)
@@ -286,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
@@ -315,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