Title: test_winsound bombing out on 2003 buildslave
Type: behavior Stage:
Components: Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: trent Nosy List: trent, vstinner
Priority: normal Keywords:

Created on 2012-08-21 02:17 by trent, last changed 2012-10-27 02:23 by trent. This issue is now closed.

Messages (4)
msg168729 - (view) Author: Trent Nelson (trent) * (Python committer) Date: 2012-08-21 02:17
The 'Windows Server 2003 R2 SP1' build slave I set up keeps bombing out on test_winsound:

FAIL: test_alias_nofallback (test.test_winsound.PlaySoundTest)
Traceback (most recent call last):
  File "E:\Data\buildslave\cpython\2.7.snakebite-win2k3r2sp2-x86\build\lib\test\", line 199, in test_alias_nofallback
    '!"$%&/(#+*', winsound.SND_ALIAS | winsound.SND_NODEFAULT
AssertionError: RuntimeError not raised

Raising this as a placeholder until I can look into it in more detail.
msg168756 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-08-21 11:46
Copy of the test:

    def test_alias_nofallback(self):
        if _have_soundcard():
            # Note that this is not the same as asserting RuntimeError
            # will get raised:  you cannot convert this to
            # self.assertRaises(...) form.  The attempt may or may not
            # raise RuntimeError, but it shouldn't raise anything other
            # than RuntimeError, and that's all we're trying to test
            # here.  The MS docs aren't clear about whether the SDK
            # PlaySound() with SND_ALIAS and SND_NODEFAULT will return
            # True or False when the alias is unknown.  On Tim's WinXP
            # box today, it returns True (no exception is raised).  What
            # we'd really like to test is that no sound is played, but
            # that requires first wiring an eardrum class into unittest
            # <wink>.
                    winsound.SND_ALIAS | winsound.SND_NODEFAULT
            except RuntimeError:
            self.assertRaises(           <~~~~ HERE
                '!"$%&/(#+*', winsound.SND_ALIAS | winsound.SND_NODEFAULT

So according to Lib/test/check_soundcard.vbs, the buildbot has no soundcard. Is this correct?
msg168843 - (view) Author: Trent Nelson (trent) * (Python committer) Date: 2012-08-22 06:40

ActivePython (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import test.test_winsound
>>> test.test_winsound._have_soundcard()
>>> import winsound
>>> winsound.PlaySound('!"$%&/(#+*', winsound.SND_ALIAS | winsound.SND_NODEFAULT)

No exception raised.  (No sound is played, either, FWIW.)

I like the approach taken by the method before test_alias_nofallback():

    def test_alias_fallback(self):
        # This test can't be expected to work on all systems.  The MS
        # PlaySound() docs say:
        #     If it cannot find the specified sound, PlaySound uses the
        #     default system event sound entry instead.  If the function
        #     can find neither the system default entry nor the default
        #     sound, it makes no sound and returns FALSE.
        # It's known to return FALSE on some real systems.

        # winsound.PlaySound('!"$%&/(#+*', winsound.SND_ALIAS)

I suspect that'll solve all our problems ;-)
msg173910 - (view) Author: Trent Nelson (trent) * (Python committer) Date: 2012-10-27 02:23
We avoided this by adding -u-audio to the affected slave.
Date User Action Args
2012-10-27 02:23:55trentsetstatus: open -> closed
resolution: fixed
messages: + msg173910
2012-08-22 06:40:15trentsetmessages: + msg168843
2012-08-21 11:46:55vstinnersetnosy: + vstinner
messages: + msg168756
2012-08-21 02:17:31trentcreate