Skip to content

Commit

Permalink
fix: Fix callable check under PyPy2 (#149)
Browse files Browse the repository at this point in the history
* Fix callable check under PyPy2

With PyPy (at least version 2.7.3), methodcaller generated callables do have a __name__ attribute, so _callable_str() will not attempt to stringify it making this unit fail.

* Update test_schema.py

Forgot a reason kwarg
  • Loading branch information
cfs-pure authored and skorokithakis committed May 5, 2018
1 parent bb85647 commit 3054d7e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import re
import sys
import copy
import platform

from pytest import raises
from pytest import raises, mark

from schema import (Schema, Use, And, Or, Regex, Optional, Const,
SchemaError, SchemaWrongKeyError,
Expand Down Expand Up @@ -507,6 +508,9 @@ def test_missing_keys_exception_with_non_str_dict_keys():
raise


# PyPy does have a __name__ attribute for its callables.
@mark.skipif(platform.python_implementation() == 'PyPy',
reason='Running on PyPy')
def test_issue_56_cant_rely_on_callables_to_have_name():
s = Schema(methodcaller('endswith', '.csv'))
assert s.validate('test.csv') == 'test.csv'
Expand Down

0 comments on commit 3054d7e

Please sign in to comment.