@@ -473,96 +473,65 @@ class X(Structure):
473
473
self .assertEqual (s .first , got .first )
474
474
self .assertEqual (s .second , got .second )
475
475
476
- @unittest .skipIf (_architecture () == ('64bit' , 'WindowsPE' ), "can't test Windows x64 build" )
477
- def test_issue18060_a (self ):
476
+ def _test_issue18060 (self , Vector ):
478
477
# The call to atan2() should succeed if the
479
478
# class fields were correctly cloned in the
480
479
# subclasses. Otherwise, it will segfault.
481
- #
482
- # This test case calls
483
- # PyCStructUnionType_update_stgdict() for each
484
- # _fields_ assignment, and PyCStgDict_clone()
485
- # for the Mid and Vector class definitions.
486
480
if sys .platform == 'win32' :
487
481
libm = CDLL (find_library ('msvcrt.dll' ))
488
482
else :
489
483
libm = CDLL (find_library ('m' ))
490
484
485
+ libm .atan2 .argtypes = [Vector ]
486
+ libm .atan2 .restype = c_double
487
+
488
+ arg = Vector (y = 0.0 , x = - 1.0 )
489
+ self .assertAlmostEqual (libm .atan2 (arg ), 3.141592653589793 )
490
+
491
+ @unittest .skipIf (_architecture () == ('64bit' , 'WindowsPE' ), "can't test Windows x64 build" )
492
+ @unittest .skipUnless (sys .byteorder == 'little' , "can't test on this platform" )
493
+ def test_issue18060_a (self ):
494
+ # This test case calls
495
+ # PyCStructUnionType_update_stgdict() for each
496
+ # _fields_ assignment, and PyCStgDict_clone()
497
+ # for the Mid and Vector class definitions.
491
498
class Base (Structure ):
492
499
_fields_ = [('y' , c_double ),
493
500
('x' , c_double )]
494
-
495
501
class Mid (Base ):
496
502
pass
497
-
498
503
Mid ._fields_ = []
499
-
500
504
class Vector (Mid ): pass
501
-
502
- libm .atan2 .argtypes = [Vector ]
503
- libm .atan2 .restype = c_double
504
-
505
- arg = Vector (y = 0.0 , x = - 1.0 )
506
- self .assertAlmostEqual (libm .atan2 (arg ), 3.141592653589793 )
505
+ self ._test_issue18060 (Vector )
507
506
508
507
@unittest .skipIf (_architecture () == ('64bit' , 'WindowsPE' ), "can't test Windows x64 build" )
508
+ @unittest .skipUnless (sys .byteorder == 'little' , "can't test on this platform" )
509
509
def test_issue18060_b (self ):
510
- # The call to atan2() should succeed if the
511
- # class fields were correctly cloned in the
512
- # subclasses. Otherwise, it will segfault.
513
- #
514
510
# This test case calls
515
511
# PyCStructUnionType_update_stgdict() for each
516
512
# _fields_ assignment.
517
- if sys .platform == 'win32' :
518
- libm = CDLL (find_library ('msvcrt.dll' ))
519
- else :
520
- libm = CDLL (find_library ('m' ))
521
-
522
513
class Base (Structure ):
523
514
_fields_ = [('y' , c_double ),
524
515
('x' , c_double )]
525
-
526
516
class Mid (Base ):
527
517
_fields_ = []
528
-
529
518
class Vector (Mid ):
530
519
_fields_ = []
531
-
532
- libm .atan2 .argtypes = [Vector ]
533
- libm .atan2 .restype = c_double
534
-
535
- arg = Vector (y = 0.0 , x = - 1.0 )
536
- self .assertAlmostEqual (libm .atan2 (arg ), 3.141592653589793 )
520
+ self ._test_issue18060 (Vector )
537
521
538
522
@unittest .skipIf (_architecture () == ('64bit' , 'WindowsPE' ), "can't test Windows x64 build" )
523
+ @unittest .skipUnless (sys .byteorder == 'little' , "can't test on this platform" )
539
524
def test_issue18060_c (self ):
540
- # The call to atan2() should succeed if the
541
- # class fields were correctly cloned in the
542
- # subclasses. Otherwise, it will segfault.
543
- #
544
525
# This test case calls
545
526
# PyCStructUnionType_update_stgdict() for each
546
527
# _fields_ assignment.
547
- if sys .platform == 'win32' :
548
- libm = CDLL (find_library ('msvcrt.dll' ))
549
- else :
550
- libm = CDLL (find_library ('m' ))
551
-
552
528
class Base (Structure ):
553
529
_fields_ = [('y' , c_double )]
554
-
555
530
class Mid (Base ):
556
531
_fields_ = []
557
-
558
532
class Vector (Mid ):
559
533
_fields_ = [('x' , c_double )]
560
-
561
- libm .atan2 .argtypes = [Vector ]
562
- libm .atan2 .restype = c_double
563
-
564
- arg = Vector (y = 0.0 , x = - 1.0 )
565
- self .assertAlmostEqual (libm .atan2 (arg ), 3.141592653589793 )
534
+ self ._test_issue18060 (Vector )
566
535
567
536
def test_array_in_struct (self ):
568
537
# See bpo-22273
0 commit comments