13
13
from ._warnings import expected_warnings
14
14
15
15
from nose2 .compat import unittest
16
- from unittest import TestCase
16
+ from unittest import TestCase , skipif
17
17
from nose2 .tools .such import helper as testhelper
18
18
19
19
from traitlets import (
24
24
ForwardDeclaredType , ForwardDeclaredInstance , validate , observe , default ,
25
25
observe_compat , BaseDescriptor , HasDescriptors ,
26
26
)
27
- from ipython_genutils import py3compat
27
+
28
+ import six
28
29
29
30
def change_dict (* ordered_values ):
30
31
change_names = ('name' , 'old' , 'new' , 'owner' , 'type' )
@@ -1143,30 +1144,30 @@ class TestInt(TraitTestBase):
1143
1144
_bad_values = ['ten' , u'ten' , [10 ], {'ten' : 10 }, (10 ,), None , 1j ,
1144
1145
10.1 , - 10.1 , '10L' , '-10L' , '10.1' , '-10.1' , u'10L' ,
1145
1146
u'-10L' , u'10.1' , u'-10.1' , '10' , '-10' , u'10' , - 200 ]
1146
- if not py3compat .PY3 :
1147
+ if not six .PY3 :
1147
1148
_bad_values .extend ([long (10 ), long (- 10 ), 10 * sys .maxint , - 10 * sys .maxint ])
1148
1149
1149
1150
1150
1151
class LongTrait (HasTraits ):
1151
1152
1152
- value = Long (99 if py3compat .PY3 else long (99 ))
1153
+ value = Long (99 if six .PY3 else long (99 ))
1153
1154
1154
1155
class TestLong (TraitTestBase ):
1155
1156
1156
1157
obj = LongTrait ()
1157
1158
1158
- _default_value = 99 if py3compat .PY3 else long (99 )
1159
+ _default_value = 99 if six .PY3 else long (99 )
1159
1160
_good_values = [10 , - 10 ]
1160
1161
_bad_values = ['ten' , u'ten' , [10 ], {'ten' : 10 },(10 ,),
1161
1162
None , 1j , 10.1 , - 10.1 , '10' , '-10' , '10L' , '-10L' , '10.1' ,
1162
1163
'-10.1' , u'10' , u'-10' , u'10L' , u'-10L' , u'10.1' ,
1163
1164
u'-10.1' ]
1164
- if not py3compat .PY3 :
1165
+ if not six .PY3 :
1165
1166
# maxint undefined on py3, because int == long
1166
1167
_good_values .extend ([long (10 ), long (- 10 ), 10 * sys .maxint , - 10 * sys .maxint ])
1167
1168
_bad_values .extend ([[long (10 )], (long (10 ),)])
1168
1169
1169
- @unittest . skipIf ( py3compat .PY3 , "not relevant on py3" )
1170
+ @skipif ( six .PY3 , "not relevant on py3" )
1170
1171
def test_cast_small (self ):
1171
1172
"""Long casts ints to long"""
1172
1173
self .obj .value = 10
@@ -1183,10 +1184,10 @@ class TestInteger(TestLong):
1183
1184
def coerce (self , n ):
1184
1185
return int (n )
1185
1186
1186
- @unittest . skipIf ( py3compat .PY3 , "not relevant on py3" )
1187
+ @skipif ( six .PY3 , "not relevant on py3" )
1187
1188
def test_cast_small (self ):
1188
1189
"""Integer casts small longs to int"""
1189
- if py3compat .PY3 :
1190
+ if six .PY3 :
1190
1191
raise unittest .SkipTest ("not relevant on py3" )
1191
1192
1192
1193
self .obj .value = long (100 )
@@ -1206,7 +1207,7 @@ class TestFloat(TraitTestBase):
1206
1207
_bad_values = ['ten' , u'ten' , [10 ], {'ten' : 10 }, (10 ,), None ,
1207
1208
1j , '10' , '-10' , '10L' , '-10L' , '10.1' , '-10.1' , u'10' ,
1208
1209
u'-10' , u'10L' , u'-10L' , u'10.1' , u'-10.1' , 201.0 ]
1209
- if not py3compat .PY3 :
1210
+ if not six .PY3 :
1210
1211
_bad_values .extend ([long (10 ), long (- 10 )])
1211
1212
1212
1213
@@ -1222,7 +1223,7 @@ class TestComplex(TraitTestBase):
1222
1223
_good_values = [10 , - 10 , 10.1 , - 10.1 , 10j , 10 + 10j , 10 - 10j ,
1223
1224
10.1j , 10.1 + 10.1j , 10.1 - 10.1j ]
1224
1225
_bad_values = [u'10L' , u'-10L' , 'ten' , [10 ], {'ten' : 10 },(10 ,), None ]
1225
- if not py3compat .PY3 :
1226
+ if not six .PY3 :
1226
1227
_bad_values .extend ([long (10 ), long (- 10 )])
1227
1228
1228
1229
@@ -1239,7 +1240,7 @@ class TestBytes(TraitTestBase):
1239
1240
b'-10L' , b'10.1' , b'-10.1' , b'string' ]
1240
1241
_bad_values = [10 , - 10 , 10.1 , - 10.1 , 1j , [10 ],
1241
1242
['ten' ],{'ten' : 10 },(10 ,), None , u'string' ]
1242
- if not py3compat .PY3 :
1243
+ if not six .PY3 :
1243
1244
_bad_values .extend ([long (10 ), long (- 10 )])
1244
1245
1245
1246
@@ -1256,7 +1257,7 @@ class TestUnicode(TraitTestBase):
1256
1257
'-10.1' , '' , u'' , 'string' , u'string' , u"€" ]
1257
1258
_bad_values = [10 , - 10 , 10.1 , - 10.1 , 1j ,
1258
1259
[10 ], ['ten' ], [u'ten' ], {'ten' : 10 },(10 ,), None ]
1259
- if not py3compat .PY3 :
1260
+ if not six .PY3 :
1260
1261
_bad_values .extend ([long (10 ), long (- 10 )])
1261
1262
1262
1263
0 commit comments