11import os
2+ import platform
23import sys
34import unittest
45
@@ -51,6 +52,10 @@ def todo_test_get(self):
5152 """Ensures get works as expected."""
5253 self .fail ()
5354
55+ @unittest .skipIf (
56+ platform .system () != "Windows" ,
57+ "scrap features are broken on non windows platforms" ,
58+ )
5459 def test_get__owned_empty_type (self ):
5560 """Ensures get works when there is no data of the requested type
5661 in the clipboard and the clipboard is owned by the pygame application.
@@ -95,7 +100,10 @@ def test_put__text(self):
95100
96101 self .assertEqual (scrap .get (pygame .SCRAP_TEXT ), b"Another String" )
97102
98- @unittest .skipIf ("pygame.image" not in sys .modules , "requires pygame.image module" )
103+ @unittest .skipIf (
104+ platform .system () != "Windows" ,
105+ "scrap features are broken on non windows platforms" ,
106+ )
99107 def test_put__bmp_image (self ):
100108 """Ensures put can place a BMP image into the clipboard."""
101109 sf = pygame .image .load (trunk_relative_path ("examples/data/asprite.bmp" ))
@@ -104,6 +112,10 @@ def test_put__bmp_image(self):
104112
105113 self .assertEqual (scrap .get (pygame .SCRAP_BMP ), expected_bytes )
106114
115+ @unittest .skipIf (
116+ platform .system () != "Windows" ,
117+ "scrap features are broken on non windows platforms" ,
118+ )
107119 def test_put (self ):
108120 """Ensures put can place data into the clipboard
109121 when using a user defined type identifier.
@@ -205,59 +217,6 @@ def test_lost__not_owned(self):
205217 self .assertTrue (lost )
206218
207219
208- class X11InteractiveTest (unittest .TestCase ):
209- __tags__ = ["ignore" , "subprocess_ignore" ]
210- try :
211- pygame .display .init ()
212- except Exception :
213- pass
214- else :
215- if pygame .display .get_driver () == "x11" :
216- __tags__ = ["interactive" ]
217- pygame .display .quit ()
218-
219- def test_issue_223 (self ):
220- """PATCH: pygame.scrap on X11, fix copying into PRIMARY selection
221-
222- Copying into theX11 PRIMARY selection (mouse copy/paste) would not
223- work due to a confusion between content type and clipboard type.
224-
225- """
226-
227- from pygame import display , event , freetype
228- from pygame .locals import KEYDOWN , QUIT , SCRAP_SELECTION , SCRAP_TEXT , K_y
229-
230- success = False
231- freetype .init ()
232- font = freetype .Font (None , 24 )
233- display .init ()
234- display .set_caption ("Interactive X11 Paste Test" )
235- screen = display .set_mode ((600 , 200 ))
236- screen .fill (pygame .Color ("white" ))
237- text = "Scrap put() succeeded."
238- msg = (
239- "Some text has been placed into the X11 clipboard."
240- " Please click the center mouse button in an open"
241- " text window to retrieve it."
242- '\n \n Did you get "{}"? (y/n)'
243- ).format (text )
244- word_wrap (screen , msg , font , 6 )
245- display .flip ()
246- event .pump ()
247- scrap .init ()
248- scrap .set_mode (SCRAP_SELECTION )
249- scrap .put (SCRAP_TEXT , text .encode ("UTF-8" ))
250- while True :
251- e = event .wait ()
252- if e .type == QUIT :
253- break
254- if e .type == KEYDOWN :
255- success = e .key == K_y
256- break
257- pygame .display .quit ()
258- self .assertTrue (success )
259-
260-
261220def word_wrap (surf , text , font , margin = 0 , color = (0 , 0 , 0 )):
262221 font .origin = True
263222 surf_width , surf_height = surf .get_size ()
0 commit comments