Skip to content

Commit

Permalink
Remove PyPy support and add tests to make the migration easier
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainDe committed Apr 2, 2015
1 parent fd663c7 commit 5016b84
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ python:
- "3.3"
- "3.4"
- "nightly"
- "pypy"
- "pypy3"
# - "pypy"
# - "pypy3"

install:
- pip install pep8
Expand Down
6 changes: 4 additions & 2 deletions didyoumean/didyoumean_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
MATH_DOMAIN_ERROR_RE = r"^math domain error$"
TOO_MANY_VALUES_UNPACK_RE = r"^too many values " \
r"to unpack(?: \(expected \d+\))?$"
OUTSIDE_FUNCTION_RE = r"^'(\w+)' outside function$"
OUTSIDE_FUNCTION_RE = r"^'?(\w+)'? outside function$"
NEED_MORE_VALUES_RE = r"^need more than \d+ values to unpack$"
UNHASHABLE_RE = r"^unhashable type: '(\w+)'$"
UNHASHABLE_RE = r"^(?:unhashable type: )?'(\w+)'(?: objects are unhashable)?$"
MISSING_PARENT_RE = r"^Missing parentheses in call to '(\w+)'$"
INVALID_LITERAL_RE = r"^invalid literal for (\w+)\(\) with base \d+: '(\w+)'$"
NB_ARG_RE = r"^(\w+)\(\) takes (?:exactly )?\d+ " \
r"(?:positional )?argument \(?(?:but )?\d+ (?:were )?given\)?$"
INVALID_SYNTAX_RE = r"^invalid syntax$"
INVALID_COMP_RE = r"^invalid comparison$"
EXPECTED_LENGTH_RE = r"^expected length (\d+), got (\d+)$"
29 changes: 24 additions & 5 deletions didyoumean/didyoumean_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
NOMODULE_RE, CANNOTIMPORT_RE, INDEXOUTOFRANGE_RE, ZERO_LEN_FIELD_RE,\
MATH_DOMAIN_ERROR_RE, TOO_MANY_VALUES_UNPACK_RE, OUTSIDE_FUNCTION_RE,\
NEED_MORE_VALUES_RE, UNHASHABLE_RE, MISSING_PARENT_RE, INVALID_LITERAL_RE,\
NB_ARG_RE, INVALID_SYNTAX_RE
NB_ARG_RE, INVALID_SYNTAX_RE, EXPECTED_LENGTH_RE, INVALID_COMP_RE
import unittest2
import math
import sys
Expand Down Expand Up @@ -151,6 +151,7 @@ def throws(self, code, error_info, sugg=None, version_range=ALL_VERSIONS):
INVALIDSYNTAX = (SyntaxError, INVALID_SYNTAX_RE)
OUTSIDEFUNC = (SyntaxError, OUTSIDE_FUNCTION_RE)
MISSINGPARENT = (SyntaxError, MISSING_PARENT_RE)
INVALIDCOMP = (SyntaxError, INVALID_COMP_RE)


class NameErrorTests(AbstractTests):
Expand Down Expand Up @@ -800,14 +801,20 @@ def test_too_many_values(self):
def test_unhashable_type(self):
""" Test UNHASHABLE_RE ."""
# Python 2.6/2.7/3.2/3.3/3.4/3.5
s = "unhashable type: 'list'"
self.regex_matches(s, UNHASHABLE_RE, ('list',))
s1 = "unhashable type: 'list'"
# PyPy/PyPy3
s2 = "'list' objects are unhashable"
self.regex_matches(s1, UNHASHABLE_RE, ('list',))
self.regex_matches(s2, UNHASHABLE_RE, ('list',))

def test_outside_function(self):
""" Test OUTSIDE_FUNCTION_RE ."""
# Python 2.6/2.7/3.2/3.3/3.4/3.5
s = "'return' outside function"
self.regex_matches(s, OUTSIDE_FUNCTION_RE, ('return',))
s1 = "'return' outside function"
# PyPy/PyPy3
s2 = "return outside function"
self.regex_matches(s1, OUTSIDE_FUNCTION_RE, ('return',))
self.regex_matches(s2, OUTSIDE_FUNCTION_RE, ('return',))

def test_nb_positional_argument(self):
""" Test NB_ARG_RE ."""
Expand Down Expand Up @@ -846,6 +853,18 @@ def test_invalid_syntax(self):
s = "invalid syntax"
self.regex_matches(s, INVALID_SYNTAX_RE, ())

def test_invalid_comp(self):
""" Test INVALID_COMP_RE ."""
# PyPy3
s = "invalid comparison"
self.regex_matches(s, INVALID_COMP_RE, ())

def test_expected_length(self):
""" Test EXPECTED_LENGTH_RE ."""
# PyPy
s = "expected length 3, got 2"
self.regex_matches(s, EXPECTED_LENGTH_RE, ('3', '2'))


class GetSuggStringTests(unittest2.TestCase):
""" Tests about get_suggestion_string. """
Expand Down

0 comments on commit 5016b84

Please sign in to comment.