1
1
import os
2
+ import platform
2
3
import sys
3
4
import unittest
4
5
@@ -51,6 +52,10 @@ def todo_test_get(self):
51
52
"""Ensures get works as expected."""
52
53
self .fail ()
53
54
55
+ @unittest .skipIf (
56
+ platform .system () != "Windows" ,
57
+ "scrap features are broken on non windows platforms" ,
58
+ )
54
59
def test_get__owned_empty_type (self ):
55
60
"""Ensures get works when there is no data of the requested type
56
61
in the clipboard and the clipboard is owned by the pygame application.
@@ -95,7 +100,10 @@ def test_put__text(self):
95
100
96
101
self .assertEqual (scrap .get (pygame .SCRAP_TEXT ), b"Another String" )
97
102
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
+ )
99
107
def test_put__bmp_image (self ):
100
108
"""Ensures put can place a BMP image into the clipboard."""
101
109
sf = pygame .image .load (trunk_relative_path ("examples/data/asprite.bmp" ))
@@ -104,6 +112,10 @@ def test_put__bmp_image(self):
104
112
105
113
self .assertEqual (scrap .get (pygame .SCRAP_BMP ), expected_bytes )
106
114
115
+ @unittest .skipIf (
116
+ platform .system () != "Windows" ,
117
+ "scrap features are broken on non windows platforms" ,
118
+ )
107
119
def test_put (self ):
108
120
"""Ensures put can place data into the clipboard
109
121
when using a user defined type identifier.
@@ -205,59 +217,6 @@ def test_lost__not_owned(self):
205
217
self .assertTrue (lost )
206
218
207
219
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
-
261
220
def word_wrap (surf , text , font , margin = 0 , color = (0 , 0 , 0 )):
262
221
font .origin = True
263
222
surf_width , surf_height = surf .get_size ()
0 commit comments