diff --git a/.travis.yml b/.travis.yml index 6d9be83..2f7b13e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ python: - 3.5 - 3.6 - 3.7 +- 3.8 - pypy2.7-6.0 - pypy3.5 diff --git a/setup.py b/setup.py index 292bce2..a78d922 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ def file_to_string(*path): 'littleutils', ] -if 'pypy' not in sys.version.lower() and sys.version_info[:2] not in [(3, 4), (3, 8)]: +if 'pypy' not in sys.version.lower() and sys.version_info[:2] not in [(3, 4)]: tests_require += [ 'numpy>=1.16.3', 'pandas>=0.24.2', diff --git a/snoop/tracer.py b/snoop/tracer.py index 14cbda1..ae20793 100644 --- a/snoop/tracer.py +++ b/snoop/tracer.py @@ -11,7 +11,7 @@ from cheap_repr import cheap_repr, find_repr_function from snoop.utils import my_cheap_repr, NO_ASTTOKENS, ArgDefaultDict, iscoroutinefunction, \ - truncate_list, ensure_tuple, is_comprehension_frame, no_args_decorator, pp_name_prefix + truncate_list, ensure_tuple, is_comprehension_frame, no_args_decorator, pp_name_prefix, NO_BIRDSEYE from .formatting import Event, Source from .variables import CommonVariable, Exploding, BaseVariable @@ -286,7 +286,7 @@ def __init__(self, config): self.config = config def __call__(self, *args, **kwargs): - if NO_ASTTOKENS: + if NO_BIRDSEYE: raise Exception("birdseye doesn't support this version of Python") try: diff --git a/snoop/utils.py b/snoop/utils.py index 8f705ef..3ec7b3c 100644 --- a/snoop/utils.py +++ b/snoop/utils.py @@ -7,10 +7,9 @@ import six from cheap_repr import cheap_repr, try_register_repr -NO_ASTTOKENS = ( - 'pypy' in sys.version.lower() - or sys.version_info[:2] in [(3, 4), (3, 8)] -) +NO_ASTTOKENS = sys.version_info[:2] == (3, 4) +PYPY = 'pypy' in sys.version.lower() +NO_BIRDSEYE = NO_ASTTOKENS or PYPY pp_name_prefix = '__deep_pp_hidden__' diff --git a/tests/samples/exception.py b/tests/samples/exception.py index e74f65a..8d168c0 100644 --- a/tests/samples/exception.py +++ b/tests/samples/exception.py @@ -2,9 +2,9 @@ def foo(): - raise TypeError(''' - very - bad''') + raise TypeError('\n very\n bad') + + def bar(*_): @@ -81,8 +81,7 @@ def bob(*_): 12:34:56.78 12 | str(foo()) 12:34:56.78 >>> Call to foo in File "/path/to_file.py", line 4 12:34:56.78 4 | def foo(): - 12:34:56.78 5 | raise TypeError(''' - 12:34:56.78 7 | bad''') + 12:34:56.78 5 | raise TypeError('\n very\n bad') 12:34:56.78 !!! TypeError: 12:34:56.78 !!! very 12:34:56.78 !!! bad diff --git a/tests/samples/pp.py b/tests/samples/pp.py index 266a907..2fe64eb 100644 --- a/tests/samples/pp.py +++ b/tests/samples/pp.py @@ -8,10 +8,10 @@ def main(): pp(pp(x + 1) + max(*pp(y + 2, y + 3))) assert pp.deep(lambda: x + 1 + max(y + 2, y + 3)) == 7 lst = list(range(30)) - pp.deep(lambda: list( - list(a + b for a in [1, 2]) + pp.deep(lambda: [ + [a + b for a in [1, 2]] for b in [3, 4] - ) + lst) + ] + lst) pp(dict.fromkeys(range(30), 4)) pp.deep(lambda: BadRepr() and 1) pp.deep(lambda: 1 / 2) @@ -63,35 +63,31 @@ def caller(f): 12:34:56.78 10 | lst = list(range(30)) 12:34:56.78 .......... lst = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ..., 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29] 12:34:56.78 .......... len(lst) = 30 -12:34:56.78 11 | pp.deep(lambda: list( +12:34:56.78 11 | pp.deep(lambda: [ 12:34:56.78 LOG: -12:34:56.78 ............ list(a + b for a in [1, 2]) -12:34:56.78 for b in [3, 4] = at 0xABC> -12:34:56.78 .................... a + b for a in [1, 2] = at 0xABC> -12:34:56.78 ............................ a = 1 -12:34:56.78 ............................ b = 3 -12:34:56.78 ........................ a + b = 4 -12:34:56.78 ............................ a = 2 -12:34:56.78 ............................ b = 3 -12:34:56.78 ........................ a + b = 5 -12:34:56.78 ................ list(a + b for a in [1, 2]) = [4, 5] -12:34:56.78 .................... a + b for a in [1, 2] = at 0xABC> -12:34:56.78 ............................ a = 1 -12:34:56.78 ............................ b = 4 -12:34:56.78 ........................ a + b = 5 -12:34:56.78 ............................ a = 2 -12:34:56.78 ............................ b = 4 -12:34:56.78 ........................ a + b = 6 -12:34:56.78 ................ list(a + b for a in [1, 2]) = [5, 6] -12:34:56.78 ........ list( -12:34:56.78 list(a + b for a in [1, 2]) +12:34:56.78 .................... a = 1 +12:34:56.78 .................... b = 3 +12:34:56.78 ................ a + b = 4 +12:34:56.78 .................... a = 2 +12:34:56.78 .................... b = 3 +12:34:56.78 ................ a + b = 5 +12:34:56.78 ............ [a + b for a in [1, 2]] = [4, 5] +12:34:56.78 .................... a = 1 +12:34:56.78 .................... b = 4 +12:34:56.78 ................ a + b = 5 +12:34:56.78 .................... a = 2 +12:34:56.78 .................... b = 4 +12:34:56.78 ................ a + b = 6 +12:34:56.78 ............ [a + b for a in [1, 2]] = [5, 6] +12:34:56.78 ........ [ +12:34:56.78 [a + b for a in [1, 2]] 12:34:56.78 for b in [3, 4] -12:34:56.78 ) = [[4, 5], [5, 6]] +12:34:56.78 ] = [[4, 5], [5, 6]] 12:34:56.78 ........ lst = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29] -12:34:56.78 .... list( -12:34:56.78 list(a + b for a in [1, 2]) +12:34:56.78 .... [ +12:34:56.78 [a + b for a in [1, 2]] 12:34:56.78 for b in [3, 4] -12:34:56.78 ) + lst = [[4, 5], +12:34:56.78 ] + lst = [[4, 5], 12:34:56.78 [5, 6], 12:34:56.78 0, 12:34:56.78 1, diff --git a/tests/test_snoop.py b/tests/test_snoop.py index 5ce1a9d..c191b80 100644 --- a/tests/test_snoop.py +++ b/tests/test_snoop.py @@ -16,7 +16,7 @@ from snoop import formatting, install, spy from snoop.configuration import Config from snoop.pp_module import is_deep_arg -from snoop.utils import truncate_string, truncate_list, needs_parentheses, NO_ASTTOKENS +from snoop.utils import truncate_string, truncate_list, needs_parentheses, NO_ASTTOKENS, NO_BIRDSEYE, PYPY current_thread()._ident = current_thread()._Thread__ident = 123456789 @@ -116,13 +116,18 @@ def test_samples(): continue if NO_ASTTOKENS: - if module_name in 'pandas_sample spy pp pp_exception enabled exception color color2'.split(): - continue - if module_name in 'no_asttokens_color' and six.PY2: + if module_name in 'pp pp_exception exception color color2'.split(): continue else: if module_name.startswith('no_asttokens'): continue + if PYPY or sys.version_info[:2] == (3, 4): + if module_name in 'pandas_sample'.split(): + continue + if NO_BIRDSEYE: + if module_name in 'spy enabled'.split(): + continue + if module_name in 'f_string' and sys.version_info[:2] < (3, 6): continue diff --git a/tox.ini b/tox.ini index 977b2ca..598fe6b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,11 @@ [tox] envlist = - py{27,34,35,36,37,py,py3} + py{27,34,35,36,37,38,py,py3} [testenv] -description = Unit tests +deps = + .[tests] commands = - sh -c 'python -c "import pytest" || pip install .[tests]' pytest -vv -setenv = - # until python_toolbox is fixed - PYTHONWARNINGS = ignore::DeprecationWarning -whitelist_externals = - sh passenv = FIX_SNOOP_TESTS