Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change behaviour of same_type function #135

Merged
merged 2 commits into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/RestrictedPython/Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def same_type(arg1, *args):
t = getattr(arg1, '__class__', type(arg1))
for arg in args:
if getattr(arg, '__class__', type(arg)) is not t:
return 0
return 1
return False
return True


utility_builtins['same_type'] = same_type
Expand Down
4 changes: 2 additions & 2 deletions tests/builtins/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_sametype_only_two_args_different():

class Foo(object):
pass
assert same_type(object(), Foo()) is 0
assert same_type(object(), Foo()) is False


def test_sametype_only_multiple_args_same():
Expand All @@ -89,7 +89,7 @@ def test_sametype_only_multipe_args_one_different():

class Foo(object):
pass
assert same_type(object(), object(), Foo()) is 0
assert same_type(object(), object(), Foo()) is False


def test_test_single_value_true():
Expand Down