|
13 | 13 | rint, |
14 | 14 | arange, |
15 | 15 | __version__ as np_version, |
| 16 | + array, |
16 | 17 | ) |
17 | 18 |
|
18 | 19 | import pygame |
@@ -487,17 +488,19 @@ def do_blit(surf, arr): |
487 | 488 |
|
488 | 489 | # this test should be removed soon, when the function is deleted |
489 | 490 | def test_get_arraytype(self): |
490 | | - array_type = pygame.surfarray.get_arraytype() |
| 491 | + with self.assertWarns(DeprecationWarning): |
| 492 | + array_type = pygame.surfarray.get_arraytype() |
491 | 493 |
|
492 | | - self.assertEqual(array_type, "numpy", f"unknown array type {array_type}") |
| 494 | + self.assertEqual(array_type, "numpy", f"unknown array type {array_type}") |
493 | 495 |
|
494 | 496 | # this test should be removed soon, when the function is deleted |
495 | 497 | def test_get_arraytypes(self): |
496 | | - arraytypes = pygame.surfarray.get_arraytypes() |
497 | | - self.assertIn("numpy", arraytypes) |
| 498 | + with self.assertWarns(DeprecationWarning): |
| 499 | + arraytypes = pygame.surfarray.get_arraytypes() |
| 500 | + self.assertIn("numpy", arraytypes) |
498 | 501 |
|
499 | | - for atype in arraytypes: |
500 | | - self.assertEqual(atype, "numpy", f"unknown array type {atype}") |
| 502 | + for atype in arraytypes: |
| 503 | + self.assertEqual(atype, "numpy", f"unknown array type {atype}") |
501 | 504 |
|
502 | 505 | def test_make_surface(self): |
503 | 506 | # How does one properly test this with 2d arrays. It makes no sense |
@@ -711,24 +714,23 @@ def test_use_arraytype(self): |
711 | 714 | def do_use_arraytype(atype): |
712 | 715 | pygame.surfarray.use_arraytype(atype) |
713 | 716 |
|
714 | | - pygame.surfarray.use_arraytype("numpy") |
715 | | - self.assertEqual(pygame.surfarray.get_arraytype(), "numpy") |
716 | | - self.assertRaises(ValueError, do_use_arraytype, "not an option") |
| 717 | + with self.assertWarns(DeprecationWarning): |
| 718 | + pygame.surfarray.use_arraytype("numpy") |
| 719 | + self.assertEqual(pygame.surfarray.get_arraytype(), "numpy") |
| 720 | + self.assertRaises(ValueError, do_use_arraytype, "not an option") |
717 | 721 |
|
718 | 722 | def test_surf_lock(self): |
719 | 723 | sf = pygame.Surface((5, 5), 0, 32) |
720 | | - for atype in pygame.surfarray.get_arraytypes(): |
721 | | - pygame.surfarray.use_arraytype(atype) |
722 | 724 |
|
723 | | - ar = pygame.surfarray.pixels2d(sf) |
724 | | - self.assertTrue(sf.get_locked()) |
| 725 | + ar = pygame.surfarray.pixels2d(sf) |
| 726 | + self.assertTrue(sf.get_locked()) |
725 | 727 |
|
726 | | - sf.unlock() |
727 | | - self.assertTrue(sf.get_locked()) |
| 728 | + sf.unlock() |
| 729 | + self.assertTrue(sf.get_locked()) |
728 | 730 |
|
729 | | - del ar |
730 | | - self.assertFalse(sf.get_locked()) |
731 | | - self.assertEqual(sf.get_locks(), ()) |
| 731 | + del ar |
| 732 | + self.assertFalse(sf.get_locked()) |
| 733 | + self.assertEqual(sf.get_locks(), ()) |
732 | 734 |
|
733 | 735 |
|
734 | 736 | if __name__ == "__main__": |
|
0 commit comments