mhammond / pywin32

Python for Windows (pywin32) Extensions
5.07k stars 799 forks source link

Test suite: Skip DirectSound tests if there is no soundcard #1397

Open thopiekar opened 5 years ago

thopiekar commented 5 years ago

As found on: https://ci.appveyor.com/project/thopiekar/pywin32/builds/26944078/job/mkvtwsioj23onby5?fullLog=true

======================================================================
ERROR: testCreate (win32com.directsound.test.ds_test.DirectSoundCaptureTest)
DirectSoundCreate()
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\pywin32\test-base\Python27\site-packages\win32comext\directsound\test\ds_test.py", line 320, in testCreate
    d = ds.DirectSoundCaptureCreate(None, None)
com_error: (-2005401480, 'OLE error 0x88780078', None, None)
======================================================================
ERROR: testRecord (win32com.directsound.test.ds_test.DirectSoundCaptureTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\pywin32\test-base\Python27\site-packages\win32comext\directsound\test\ds_test.py", line 323, in testRecord
    d = ds.DirectSoundCaptureCreate(None, None)
com_error: (-2005401480, 'OLE error 0x88780078', None, None)
======================================================================
ERROR: testCreate (win32com.directsound.test.ds_test.DirectSoundTest)
DirectSoundCreate()
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\pywin32\test-base\Python27\site-packages\win32comext\directsound\test\ds_test.py", line 261, in testCreate
    d = ds.DirectSoundCreate(None, None)
com_error: (-2005401480, 'OLE error 0x88780078', None, None)
SKIPPED: 1 tests - Can't find test .wav file to play
SKIPPED: 17 tests - (-2147221005, 'Invalid class string', None, None)
---------------------------------------------------------------------
mhammond commented 5 years ago

Apparently 0x88780078 means there's no driver installed. If you can't find a symbolic name for that constant I'd be fine with the tests hard-coding it (with a suitable comment) and simply skipping those tests. I doubt it's worth requesting a sound-card in CI, and we might as well make the tests work for others who don't have a sound card installed.

thopiekar commented 5 years ago

Hmm, I get the same here on Windows 10 Insider Preview 20h1 with sound cards... Hardware HDA and also virtual ones of my Bluetooth headphones. Is this API maybe dead since Windows XY?

Another question regarding the thrown exception: pywintypes.com_error: (-2005401480, 'OLE error 0x88780078', None, None) What is the meaning of "-2005401480"? Is this an error code, too? If so why is it negative? Has it been converted into a wrong datatype? I'm just guessing.. 🙄

PS: "testEnumerate" doesn't fail. This one checks whether devices can be found and whether they are tuples with 3 entries. So a soundcard is there - locally on my PC and on the CI.

mhammond commented 5 years ago

The test seems to "mostly" :) pass for me on win10 - DirectSoundCreate() ... ok. The negative error code is an old artifact of python using an signed int rather than unsigned and will be unrelated - -2005401480 is 0x88780078 treated as a signed int. So I guess I meant it would be fine to hard-code -2005401480 as a value to ignore in this test with the comment referring to the hex value.