1
1
from symengine import Symbol , symbols , symarray , has_symbol , Dummy
2
2
from symengine .utilities import raises
3
+ import unittest
4
+ import platform
3
5
4
6
5
7
def test_symbol ():
@@ -8,9 +10,6 @@ def test_symbol():
8
10
assert str (x ) == "x"
9
11
assert str (x ) != "y"
10
12
assert repr (x ) == str (x )
11
- # Verify the successful use of slots.
12
- assert not hasattr (x , "__dict__" )
13
- assert not hasattr (x , "__weakref__" )
14
13
15
14
16
15
def test_symbols ():
@@ -163,6 +162,17 @@ def test_dummy():
163
162
assert xdummy1 != xdummy2
164
163
assert Dummy () != Dummy ()
165
164
assert Dummy ('x' ) != Dummy ('x' )
165
+
166
+ # Cython cdef classes on PyPy has a __dict__ attribute always
167
+ # __slots__ on PyPy are useless anyways. https://stackoverflow.com/a/23077685/4768820
168
+ @unittest .skipUnless (platform .python_implementation ()== "CPython" , "__slots__ are useless on PyPy" )
169
+ def test_slots ():
170
+ x = Dummy ('x' )
166
171
# Verify the successful use of slots.
167
- assert not hasattr (xdummy1 , "__dict__" )
168
- assert not hasattr (xdummy1 , "__weakref__" )
172
+ assert not hasattr (x , "__dict__" )
173
+ assert not hasattr (x , "__weakref__" )
174
+
175
+ x1 = Symbol ('x' )
176
+ # Verify the successful use of slots.
177
+ assert not hasattr (x , "__dict__" )
178
+ assert not hasattr (x , "__weakref__" )
0 commit comments