bro
This commit is contained in:
1 parent
de41a02749
commit
9af09cebd3
764 files changed
+54218
-78859
No files matched your search
@@ -2,12 +2,10 @@ import os
|
||||
import os.path
|
||||
import sys
|
||||
import unittest
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
import pygame
|
||||
import pygame.image
|
||||
import pygame.pkgdata
|
||||
from pygame.tests.test_utils import example_path
|
||||
import pygame, pygame.image, pygame.pkgdata
|
||||
|
||||
|
||||
imageext = sys.modules["pygame.imageext"]
|
||||
|
||||
@@ -54,26 +52,41 @@ class ImageextModuleTest(unittest.TestCase):
|
||||
"""non-ASCII unicode"""
|
||||
import shutil
|
||||
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
orig = example_path("data/alien1.png")
|
||||
temp = os.path.join(tmpdir, "你好.png")
|
||||
shutil.copy(orig, temp)
|
||||
imageext.load_extended(temp)
|
||||
orig = example_path("data/alien1.png")
|
||||
temp = os.path.join(example_path("data"), "你好.png")
|
||||
shutil.copy(orig, temp)
|
||||
try:
|
||||
im = imageext.load_extended(temp)
|
||||
finally:
|
||||
os.remove(temp)
|
||||
|
||||
def _unicode_save(self, temp_file):
|
||||
im = pygame.Surface((10, 10), 0, 32)
|
||||
try:
|
||||
with open(temp_file, "w") as f:
|
||||
pass
|
||||
os.remove(temp_file)
|
||||
except OSError:
|
||||
raise unittest.SkipTest("the path cannot be opened")
|
||||
|
||||
self.assertFalse(os.path.exists(temp_file))
|
||||
imageext.save_extended(im, temp_file)
|
||||
self.assertGreater(os.path.getsize(temp_file), 10)
|
||||
|
||||
try:
|
||||
imageext.save_extended(im, temp_file)
|
||||
|
||||
self.assertGreater(os.path.getsize(temp_file), 10)
|
||||
finally:
|
||||
try:
|
||||
os.remove(temp_file)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def test_save_unicode_path_0(self):
|
||||
"""unicode object with ASCII chars"""
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
self._unicode_save(os.path.join(tmpdir, "temp_file.png"))
|
||||
self._unicode_save("temp_file.png")
|
||||
|
||||
def test_save_unicode_path_1(self):
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
self._unicode_save(os.path.join(tmpdir, "你好.png"))
|
||||
self._unicode_save("你好.png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user