Allow subclasses of verbose manager to check verbose state directly.
This commit is contained in:
parent
51e27c0cff
commit
351e7060b8
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user