Massaging some code

This commit is contained in:
Ram Rachum 2019-06-18 20:21:51 +02:00
parent d7d3a80c16
commit 78a539a2a5
3 changed files with 9 additions and 10 deletions

View File

@ -207,7 +207,9 @@ Exclude specific keys/attributes/indices with the `exclude` parameter, e.g. `Att
Add a slice after `Indices` to only see the values within that slice, e.g. `Indices('z')[-3:]`. Add a slice after `Indices` to only see the values within that slice, e.g. `Indices('z')[-3:]`.
`PYSNOOPER_DISABLED` as an environment variable, can be used to activate or deactivate pysnooner. Pysnooper is deactivated by setting the parameter to a non-empty value, and active by default. ```console
$ export PYSNOOPER_DISABLED=1 # This makes PySnooper not do any snooping
```
# Contribute # # Contribute #

View File

@ -140,7 +140,7 @@ class FileWriter(object):
thread_global = threading.local() thread_global = threading.local()
DISABLED = os.getenv("PYSNOOPER_DISABLED", "") DISABLED = bool(os.getenv('PYSNOOPER_DISABLED', ''))
class Tracer: class Tracer:
''' '''

View File

@ -1175,7 +1175,7 @@ def test_custom_repr():
) )
def test_activate_deactivate_snoop(): def test_disable():
string_io = io.StringIO() string_io = io.StringIO()
def my_function(foo): def my_function(foo):
@ -1183,11 +1183,8 @@ def test_activate_deactivate_snoop():
y = 8 y = 8
return x + y return x + y
pysnooper.tracer.DISABLED = '1' with mini_toolbox.TempValueSetter((pysnooper.tracer, 'DISABLED'), True):
with pysnooper.snoop(string_io): with pysnooper.snoop(string_io):
result = my_function('baba') result = my_function('baba')
output = string_io.getvalue() output = string_io.getvalue()
assert output == "" assert not output
pysnooper.tracer.DISABLED = ''
test_string_io()