@@ -143,27 +143,18 @@ def testUnsetVarException(self):
143
143
self .assertRaises (TclError ,tcl .unsetvar ,'a' )
144
144
145
145
def get_integers (self ):
146
- integers = (0 , 1 , - 1 , 2 ** 31 - 1 , - 2 ** 31 , 2 ** 31 , - 2 ** 31 - 1 , 2 ** 63 - 1 , - 2 ** 63 )
147
- # bignum was added in Tcl 8.5, but its support is able only since 8.5.8.
148
- # Actually it is determined at compile time, so using get_tk_patchlevel()
149
- # is not reliable.
150
- # TODO: expose full static version.
151
- if tcl_version >= (8 , 5 ):
152
- v = get_tk_patchlevel ()
153
- if v >= (8 , 6 , 0 , 'final' ) or (8 , 5 , 8 ) <= v < (8 , 6 ):
154
- integers += (2 ** 63 , - 2 ** 63 - 1 , 2 ** 1000 , - 2 ** 1000 )
155
- return integers
146
+ return (0 , 1 , - 1 ,
147
+ 2 ** 31 - 1 , - 2 ** 31 , 2 ** 31 , - 2 ** 31 - 1 ,
148
+ 2 ** 63 - 1 , - 2 ** 63 , 2 ** 63 , - 2 ** 63 - 1 ,
149
+ 2 ** 1000 , - 2 ** 1000 )
156
150
157
151
def test_getint (self ):
158
152
tcl = self .interp .tk
159
153
for i in self .get_integers ():
160
154
self .assertEqual (tcl .getint (' %d ' % i ), i )
161
- if tcl_version >= (8 , 5 ):
162
- self .assertEqual (tcl .getint (' %#o ' % i ), i )
155
+ self .assertEqual (tcl .getint (' %#o ' % i ), i )
163
156
self .assertEqual (tcl .getint ((' %#o ' % i ).replace ('o' , '' )), i )
164
157
self .assertEqual (tcl .getint (' %#x ' % i ), i )
165
- if tcl_version < (8 , 5 ): # bignum was added in Tcl 8.5
166
- self .assertRaises (TclError , tcl .getint , str (2 ** 1000 ))
167
158
self .assertEqual (tcl .getint (42 ), 42 )
168
159
self .assertRaises (TypeError , tcl .getint )
169
160
self .assertRaises (TypeError , tcl .getint , '42' , '10' )
@@ -317,8 +308,7 @@ def check(expr, expected):
317
308
check ('"a\xbd \u20ac "' , 'a\xbd \u20ac ' )
318
309
check (r'"a\xbd\u20ac"' , 'a\xbd \u20ac ' )
319
310
check (r'"a\0b"' , 'a\x00 b' )
320
- if tcl_version >= (8 , 5 ): # bignum was added in Tcl 8.5
321
- check ('2**64' , str (2 ** 64 ))
F438
td>311
+ check ('2**64' , str (2 ** 64 ))
322
312
323
313
def test_exprdouble (self ):
324
314
tcl = self .interp
@@ -349,8 +339,7 @@ def check(expr, expected):
349
339
check ('[string length "a\xbd \u20ac "]' , 3.0 )
350
340
check (r'[string length "a\xbd\u20ac"]' , 3.0 )
351
341
self .assertRaises (TclError , tcl .exprdouble , '"abc"' )
352
- if tcl_version >= (8 , 5 ): # bignum was added in Tcl 8.5
353
- check ('2**64' , float (2 ** 64 ))
342
+ check ('2**64' , float (2 ** 64 ))
354
343
355
344
def test_exprlong (self ):
356
345
tcl = self .interp
@@ -381,8 +370,7 @@ def check(expr, expected):
381
370
check ('[string length "a\xbd \u20ac "]' , 3 )
382
371
check (r'[string length "a\xbd\u20ac"]' , 3 )
383
372
self .assertRaises (TclError , tcl .exprlong , '"abc"' )
384
- if tcl_version >= (8 , 5 ): # bignum was added in Tcl 8.5
385
- self .assertRaises (TclError , tcl .exprlong , '2**64' )
373
+ self .assertRaises (TclError , tcl .exprlong , '2**64' )
386
374
387
375
def test_exprboolean (self ):
388
376
tcl = self .interp
@@ -422,10 +410,8 @@ def check(expr, expected):
422
410
check ('[string length "a\xbd \u20ac "]' , True )
423
411
check (r'[string length "a\xbd\u20ac"]' , True )
424
412
self .assertRaises (TclError , tcl .exprboolean , '"abc"' )
425
- if tcl_version >= (8 , 5 ): # bignum was added in Tcl 8.5
426
- check ('2**64' , True )
413
+ check ('2**64' , True )
427
414
428
- @unittest .skipUnless (tcl_version >= (8 , 5 ), 'requires Tcl version >= 8.5' )
429
415
def test_booleans (self ):
430
416
tcl = self .interp
431
417
def check (expr , expected ):
@@ -455,8 +441,6 @@ def test_expr_bignum(self):
455
441
else :
456
442
self .assertEqual (result , str (i ))
457
443
self .assertIsInstance (result , str )
458
- if get_tk_patchlevel () < (8 , 5 ): # bignum was added in Tcl 8.5
459
- self .assertRaises (TclError , tcl .call , 'expr' , str (2 ** 1000 ))
460
444
461
445
def test_passing_values (self ):
462
446
def passValue (value ):
@@ -485,8 +469,6 @@ def passValue(value):
485
469
b'str\xbd ing' if self .wantobjects else 'str\xbd ing' )
486
470
for i in self .get_integers ():
487
471
self .assertEqual (passValue (i ), i if self .wantobjects else str (i ))
488
- if tcl_version < (8 , 5 ): # bignum was added in Tcl 8.5
489
- self .assertEqual (passValue (2 ** 1000 ), str (2 ** 1000 ))
490
472
for f in (0.0 , 1.0 , - 1.0 , 1 / 3 ,
491
473
sys .float_info .min , sys .float_info .max ,
492
474
- sys .float_info .min , - sys .float_info .max ):
@@ -552,8 +534,6 @@ def float_eq(actual, expected):
552
534
check (b'str\xc0 \x80 ing\xe2 \x82 \xac ' , 'str\xc0 \x80 ing\xe2 \x82 \xac ' )
553
535
for i in self .get_integers ():
554
536
check (i , str (i ))
555
- if tcl_version < (8 , 5 ): # bignum was added in Tcl 8.5
556
- check (2 ** 1000 , str (2 ** 1000 ))
557
537
for f in (0.0 , 1.0 , - 1.0 ):
558
538
check (f , repr (f ))
559
539
for f in (1 / 3.0 , sys .float_info .min , sys .float_info .max ,
@@ -600,16 +580,14 @@ def test_splitlist(self):
600
580
('1' , '2' , '3.4' )),
601
581
]
602
582
tk_patchlevel = get_tk_patchlevel ()
603
- if tcl_version >= (8 , 5 ):
604
- if not self .wantobjects or tk_patchlevel < (8 , 5 , 5 ):
605
- # Before 8.5.5 dicts were converted to lists through string
606
- expected = ('12' , '\u20ac ' , '\xe2 \x82 \xac ' , '3.4' )
607
- else :
608
- expected = (12 , '\u20ac ' , b'\xe2 \x82 \xac ' , (3.4 ,))
609
- testcases += [
610
- (call ('dict' , 'create' , 12 , '\u20ac ' , b'\xe2 \x82 \xac ' , (3.4 ,)),
611
- expected ),
612
- ]
583
+ if not self .wantobjects :
584
+ expected = ('12' , '\u20ac ' , '\xe2 \x82 \xac ' , '3.4' )
585
+ else :
586
+ expected = (12 , '\u20ac ' , b'\xe2 \x82 \xac ' , (3.4 ,))
587
+ testcases += [
588
+ (call ('dict' , 'create' , 12 , '\u20ac ' , b'\xe2 \x82 \xac ' , (3.4 ,)),
589
+ expected ),
590
+ ]
613
591
dbg_info = ('want objects? %s, Tcl version: %s, Tk patchlevel: %s'
614
592
% (self .wantobjects , tcl_version , tk_patchlevel ))
615
593
for arg , res in testcases :
@@ -642,15 +620,13 @@ def test_splitdict(self):
642
620
{'a' : (1 , 2 , 3 ) if self .wantobjects else '1 2 3' ,
643
621
'something' : 'foo' , 'status' : '' })
644
622
645
- if tcl_version >= (8 , 5 ):
646
- arg = tcl .call ('dict' , 'create' ,
647
- '-a' , (1 , 2 , 3 ), '-something' , 'foo' , 'status' , ())
648
- if not self .wantobjects or get_tk_patchlevel () < (8 , 5 , 5 ):
649
- # Before 8.5.5 dicts were converted to lists through string
650
- expected = {'a' : '1 2 3' , 'something' : 'foo' , 'status' : '' }
651
- else :
652
- expected = {'a' : (1 , 2 , 3 ), 'something' : 'foo' , 'status' : '' }
653
- self .assertEqual (splitdict (tcl , arg ), expected )
623
+ arg = tcl .call ('dict' , 'create' ,
624
+ '-a' , (1 , 2 , 3 ), '-something' , 'foo' , 'status' , ())
625
+ if not self .wantobjects :
626
+ expected = {'a' : '1 2 3' , 'something' : 'foo' , 'status' : '' }
627
+ else :
628
+ expected = {'a' : (1 , 2 , 3 ), 'something' : 'foo' , 'status' : '' }
629
+ self .assertEqual (splitdict (tcl , arg ), expected )
654
630
655
631
def test_join (self ):
656
632
join = tkinter ._join
0 commit comments