1
0
mirror of synced 2025-02-17 11:18:33 +01:00

Allow subclasses of verbose manager to check verbose state directly.

This commit is contained in:
Jennifer Taylor 2021-04-26 01:21:03 +00:00
parent 51e27c0cff
commit 351e7060b8

View File

@ -99,22 +99,22 @@ class VerboseOutputManager:
def __enter__(self) -> "VerboseOutputManager":
if self.verbose:
self.covered_class._verbose = True
self.covered_class.verbose = True
else:
self.covered_class._verbose = False
self.covered_class.verbose = False
return self
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
self.covered_class._verbose = False
self.covered_class.verbose = False
class VerboseOutput:
def __init__(self) -> None:
self._verbose: bool = False
self.verbose: bool = False
def debugging(self, verbose: bool) -> VerboseOutputManager:
return VerboseOutputManager(self, verbose)
def vprint(self, *args: Any, **kwargs: Any) -> None:
if self._verbose:
if self.verbose:
print(*args, **kwargs, file=sys.stderr)