如何从pygame.tests.run()修复失败的断言?

时间:2015-07-18 13:27:34

标签: python pygame

我已按照此处的说明成功安装了Pygame:http://brysonpayne.com/2015/01/10/setting-up-pygame-on-a-mac/

然后,我尝试按照此站点上的说明(https://www.pygame.org/docs/ref/tests.html)运行pygame测试并执行以下命令,但某些测试失败。

python3 -m pygame.tests

以下是运行后的输出(在框中向下滚动以查看错误)

skipping pygame.tests.cdrom_test (tag 'interactive')
skipping pygame.tests.midi_test (tag 'interactive')
skipping pygame.tests.scrap_test (tag 'subprocess_ignore')
skipping pygame.tests.sndarray_test (tag 'subprocess_ignore')
skipping pygame.tests.surfarray_test (tag 'subprocess_ignore')
loading pygame.tests.base_test
loading pygame.tests.blit_test
loading pygame.tests.bufferproxy_test
loading pygame.tests.camera_test
loading pygame.tests.color_test
loading pygame.tests.compat_test
loading pygame.tests.cursors_test
loading pygame.tests.display_test
loading pygame.tests.draw_test
loading pygame.tests.event_test
loading pygame.tests.fastevent_test
loading pygame.tests.font_test
loading pygame.tests.freetype_test
loading pygame.tests.ftfont_test
loading pygame.tests.gfxdraw_test
loading pygame.tests.image__save_gl_surface_test
loading pygame.tests.image_test
loading pygame.tests.imageext_test
loading pygame.tests.joystick_test
loading pygame.tests.key_test
loading pygame.tests.mask_test
loading pygame.tests.math_test
loading pygame.tests.mixer_music_test
loading pygame.tests.mixer_test
loading pygame.tests.mouse_test
loading pygame.tests.overlay_test
loading pygame.tests.pixelarray_test
loading pygame.tests.pixelcopy_test
loading pygame.tests.rect_test
loading pygame.tests.rwobject_test
loading pygame.tests.sprite_test
loading pygame.tests.surface_test
loading pygame.tests.surflock_test
loading pygame.tests.sysfont_test
loading pygame.tests.threads_test
loading pygame.tests.time_test
loading pygame.tests.transform_test
.......F......F................................................................................EF..............................................................................................E..F.EE.EE.......E.................................................................................................E...................................................................................................................................................................................................................................................................................................E...........................................
======================================================================
FAIL: BaseModuleTest.test_get_error
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/base_test.py", line 569, in test_get_error
    e)
AssertionError: Failed to open pDevice->interface via open.

======================================================================
FAIL: BaseModuleTest.test_set_error
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/base_test.py", line 586, in test_set_error
    e)
AssertionError: Failed to open pDevice->interface via open.


======================================================================
ERROR: all_tests_for (pygame.tests.event_test.AllTestCases)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/pygame.tests.event_test.py", line 1, in all_tests_for
subprocess completely failed with return code of 0
cmd:          ['/usr/local/opt/python3/bin/python3.4', '/usr/local/lib/python3.4/site-packages/pygame/tests/test_utils/test_runner.py', 'pygame.tests.event_test', '--exclude', 'interactive,subprocess_ignore,python3_ignore', '--timings', '1']
test_env:     environ({'LOGNAME': 'alf47', 'PWD': '/Users/alf47', 'PATH': '/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin', 'TMPDIR': '/var/folders/rd/q8llk3tj7vb1__fndsqmj0s40000gn/T/', 'LANG': 'en_US.UTF-8', 'SHLVL': '1', 'TERM_PROGRAM': 'Apple_Terminal', 'USER': 'alf47', '__PYVENV_LAUNCHER__': '/usr/local/bin/python3', 'SHELL': '/bin/bash', 'HOME': '/Users/alf47', '__CF_USER_TEXT_ENCODING': '0x1F5:0:0', 'Apple_PubSub_Socket_Render': '/tmp/launch-I873zl/Render', 'DISPLAY': '/tmp/launch-pIOmdy/org.macosforge.xquartz:0', 'SDL_VIDEO_X11_WMCLASS': '-m', 'TERM': 'xterm-256color', '_': '/usr/local/bin/python3', 'SSH_AUTH_SOCK': '/tmp/launch-UPbeZC/Listeners', 'TERM_PROGRAM_VERSION': '326', '__CHECKFIX1436934': '1', 'SECURITYSESSIONID': '186bd', 'TERM_SESSION_ID': '83D2C7C0-BAF4-4B9D-B2CA-2C697EDDE3D7'})
working_dir:  /usr/local/lib/python3.4/site-packages/pygame
return (top 5 lines):
loading pygame.tests.event_test


======================================================================
FAIL: FasteventModuleTest.test_get
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/fastevent_test.py", line 48, in test_get
    race_condition_notification
AssertionError: 
This test is dependent on timing. The event queue is cleared in preparation for 
tests. There is a small window where outside events from the OS may have effected
results. Try running the test again.


======================================================================
ERROR: GL_ImageSave.test_image_save_works_with_opengl_surfaces
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/image__save_gl_surface_test.py", line 37, in test_image_save_works_with_opengl_surfaces
    pygame.image.save(screen, tmp_file)
pygame.error: SavePNG: could not create png write struct

======================================================================
ERROR: ImageModuleTest.testSavePNG24
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/image_test.py", line 215, in testSavePNG24
    pygame.image.save(surf, f_path)
pygame.error: SavePNG: could not create png write struct

======================================================================
ERROR: ImageModuleTest.testSavePNG32
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/image_test.py", line 184, in testSavePNG32
    pygame.image.save(surf, f_path)
pygame.error: SavePNG: could not create png write struct

======================================================================
ERROR: ImageModuleTest.test_save
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/image_test.py", line 248, in test_save
    pygame.image.save(s, temp_filename)
pygame.error: SaveJPEG: could not open tmpimg.jpg

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/image_test.py", line 260, in test_save
    os.remove(temp_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tmpimg.jpg'

======================================================================
ERROR: ImageModuleTest.test_save_colorkey
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/image_test.py", line 275, in test_save_colorkey
    pygame.image.save(s, temp_filename)
pygame.error: SavePNG: could not open for writing

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/image_test.py", line 278, in test_save_colorkey
    os.remove(temp_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tmpimg.png'

======================================================================
FAIL: ImageModuleTest.testLoadPNG
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/image_test.py", line 82, in testLoadPNG
    self.assertEquals(pixel_x1_y1, greyish_pixel)
AssertionError: (109, 120, 129, 140) != (110, 120, 130, 140)

======================================================================
ERROR: ImageextModuleTest.test_save_unicode_path
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/imageext_test.py", line 65, in test_save_unicode_path
    imageext.save_extended(im, temp_file)
pygame.error: SavePNG: could not open for writing

======================================================================
ERROR: MixerMusicModuleTest.test_load
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/mixer_music_test.py", line 45, in test_load
    pygame.mixer.music.load(umusfn)
pygame.error: Unrecognized music format

======================================================================
ERROR: SurfaceTypeTest.test_image_convert_bug_131
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pygame/tests/surface_test.py", line 687, in test_image_convert_bug_131
    self.assertEquals( im.get_palette(),  ((0, 0, 0, 255), (255, 255, 255, 255)) )
pygame.error: Surface has no palette to get


----------------------------------------------------------------------
Ran 642 tests in 83.888s

FAILED (failures=4, errors=9)

如何修复这些错误?

软件版本:

  • Mac OS X 10.9.5
  • Python 3.4.3
  • XCode 6.2

让我知道我可以提供哪些其他可能有助于排查问题的信息

0 个答案:

没有答案