Skip to content

Commit

Permalink
Testing 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmojaki committed Dec 18, 2019
1 parent 336e763 commit a5e374f
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 52 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -7,6 +7,7 @@ python:
- 3.5
- 3.6
- 3.7
- 3.8
- pypy2.7-6.0
- pypy3.5

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions snoop/tracer.py
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
7 changes: 3 additions & 4 deletions snoop/utils.py
Expand Up @@ -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__'

Expand Down
9 changes: 4 additions & 5 deletions tests/samples/exception.py
Expand Up @@ -2,9 +2,9 @@


def foo():
raise TypeError('''
very
bad''')
raise TypeError('\n very\n bad')




def bar(*_):
Expand Down Expand Up @@ -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
Expand Down
52 changes: 24 additions & 28 deletions tests/samples/pp.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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] = <generator object <genexpr> at 0xABC>
12:34:56.78 .................... a + b for a in [1, 2] = <generator object <genexpr> 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] = <generator object <genexpr> 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,
Expand Down
13 changes: 9 additions & 4 deletions tests/test_snoop.py
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions 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

0 comments on commit a5e374f

Please sign in to comment.