Skip to content

Commit

Permalink
Merge pull request beeware#749 from student-06/fix_nonetype1
Browse files Browse the repository at this point in the history
This fixes all tests for NoneType datatype.
  • Loading branch information
eliasdorneles authored Mar 2, 2018
2 parents f82d9e8 + d826e4b commit f943341
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
16 changes: 15 additions & 1 deletion python/common/org/python/types/NoneType.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public org.python.Object __le__(org.python.Object other) {
__doc__ = ""
)
public org.python.Object __mul__(org.python.Object other) {
if (other instanceof org.python.types.Str || other instanceof org.python.types.List || other instanceof org.python.types.Tuple) {
if (org.python.types.Object.isSequence(other)) {
throw new org.python.exceptions.TypeError("can't multiply sequence by non-int of type 'NoneType'");
} else {
throw new org.python.exceptions.TypeError(
Expand All @@ -107,6 +107,20 @@ public org.python.Object __mul__(org.python.Object other) {
}
}


@org.python.Method(
__doc__ = ""
)
public org.python.Object __imul__(org.python.Object other) {
if (org.python.types.Object.isSequence(other)) {
throw new org.python.exceptions.TypeError("can't multiply sequence by non-int of type 'NoneType'");
} else {
throw new org.python.exceptions.TypeError(
String.format("unsupported operand type(s) for *=: 'NoneType' and '%s'",
Python.typeName(other.getClass())));
}
}

@org.python.Method(
__doc__ = ""
)
Expand Down
13 changes: 0 additions & 13 deletions tests/datatypes/test_NoneType.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,6 @@ class UnaryNoneTypeOperationTests(UnaryOperationTestCase, TranspileTestCase):
class BinaryNoneTypeOperationTests(BinaryOperationTestCase, TranspileTestCase):
data_type = 'None'

not_implemented = [
'test_multiply_bytes',
'test_multiply_bytearray',
]


class InplaceNoneTypeOperationTests(InplaceOperationTestCase, TranspileTestCase):
data_type = 'None'

not_implemented = [
'test_multiply_bytes',
'test_multiply_bytearray',
'test_multiply_list',
'test_multiply_str',
'test_multiply_tuple',
]

0 comments on commit f943341

Please sign in to comment.