Back to index

python3.2  3.2.2
Public Member Functions
test.test_winsound.PlaySoundTest Class Reference

List of all members.

Public Member Functions

def test_errors
def test_alias_asterisk
def test_alias_exclamation
def test_alias_exit
def test_alias_hand
def test_alias_question
def test_alias_fallback
def test_alias_nofallback
def test_stopasync

Detailed Description

Definition at line 95 of file test_winsound.py.


Member Function Documentation

Definition at line 108 of file test_winsound.py.

00108 
00109     def test_alias_asterisk(self):
00110         if _have_soundcard():
00111             winsound.PlaySound('SystemAsterisk', winsound.SND_ALIAS)
00112         else:
00113             self.assertRaises(
00114                 RuntimeError,
00115                 winsound.PlaySound,
00116                 'SystemAsterisk', winsound.SND_ALIAS
00117             )

Here is the call graph for this function:

Definition at line 120 of file test_winsound.py.

00120 
00121     def test_alias_exclamation(self):
00122         if _have_soundcard():
00123             winsound.PlaySound('SystemExclamation', winsound.SND_ALIAS)
00124         else:
00125             self.assertRaises(
00126                 RuntimeError,
00127                 winsound.PlaySound,
00128                 'SystemExclamation', winsound.SND_ALIAS
00129             )

Here is the call graph for this function:

Definition at line 131 of file test_winsound.py.

00131 
00132     def test_alias_exit(self):
00133         if _have_soundcard():
00134             winsound.PlaySound('SystemExit', winsound.SND_ALIAS)
00135         else:
00136             self.assertRaises(
00137                 RuntimeError,
00138                 winsound.PlaySound,
00139                 'SystemExit', winsound.SND_ALIAS
00140             )

Here is the call graph for this function:

Definition at line 164 of file test_winsound.py.

00164 
00165     def test_alias_fallback(self):
00166         # This test can't be expected to work on all systems.  The MS
00167         # PlaySound() docs say:
00168         #
00169         #     If it cannot find the specified sound, PlaySound uses the
00170         #     default system event sound entry instead.  If the function
00171         #     can find neither the system default entry nor the default
00172         #     sound, it makes no sound and returns FALSE.
00173         #
00174         # It's known to return FALSE on some real systems.
00175 
00176         # winsound.PlaySound('!"$%&/(#+*', winsound.SND_ALIAS)
00177         return

Definition at line 142 of file test_winsound.py.

00142 
00143     def test_alias_hand(self):
00144         if _have_soundcard():
00145             winsound.PlaySound('SystemHand', winsound.SND_ALIAS)
00146         else:
00147             self.assertRaises(
00148                 RuntimeError,
00149                 winsound.PlaySound,
00150                 'SystemHand', winsound.SND_ALIAS
00151             )

Here is the call graph for this function:

Definition at line 178 of file test_winsound.py.

00178 
00179     def test_alias_nofallback(self):
00180         if _have_soundcard():
00181             # Note that this is not the same as asserting RuntimeError
00182             # will get raised:  you cannot convert this to
00183             # self.assertRaises(...) form.  The attempt may or may not
00184             # raise RuntimeError, but it shouldn't raise anything other
00185             # than RuntimeError, and that's all we're trying to test
00186             # here.  The MS docs aren't clear about whether the SDK
00187             # PlaySound() with SND_ALIAS and SND_NODEFAULT will return
00188             # True or False when the alias is unknown.  On Tim's WinXP
00189             # box today, it returns True (no exception is raised).  What
00190             # we'd really like to test is that no sound is played, but
00191             # that requires first wiring an eardrum class into unittest
00192             # <wink>.
00193             try:
00194                 winsound.PlaySound(
00195                     '!"$%&/(#+*',
00196                     winsound.SND_ALIAS | winsound.SND_NODEFAULT
00197                 )
00198             except RuntimeError:
00199                 pass
00200         else:
00201             self.assertRaises(
00202                 RuntimeError,
00203                 winsound.PlaySound,
00204                 '!"$%&/(#+*', winsound.SND_ALIAS | winsound.SND_NODEFAULT
00205             )

Here is the call graph for this function:

Definition at line 154 of file test_winsound.py.

00154 
00155     def test_alias_question(self):
00156         if _have_soundcard():
00157             winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS)
00158         else:
00159             self.assertRaises(
00160                 RuntimeError,
00161                 winsound.PlaySound,
00162                 'SystemQuestion', winsound.SND_ALIAS
00163             )

Here is the call graph for this function:

Definition at line 97 of file test_winsound.py.

00097 
00098     def test_errors(self):
00099         self.assertRaises(TypeError, winsound.PlaySound)
00100         self.assertRaises(TypeError, winsound.PlaySound, "bad", "bad")
00101         self.assertRaises(
00102             RuntimeError,
00103             winsound.PlaySound,
00104             "none", winsound.SND_ASYNC | winsound.SND_MEMORY
00105         )

Here is the call graph for this function:

Definition at line 206 of file test_winsound.py.

00206 
00207     def test_stopasync(self):
00208         if _have_soundcard():
00209             winsound.PlaySound(
00210                 'SystemQuestion',
00211                 winsound.SND_ALIAS | winsound.SND_ASYNC | winsound.SND_LOOP
00212             )
00213             time.sleep(0.5)
00214             try:
00215                 winsound.PlaySound(
00216                     'SystemQuestion',
00217                     winsound.SND_ALIAS | winsound.SND_NOSTOP
00218                 )
00219             except RuntimeError:
00220                 pass
00221             else: # the first sound might already be finished
00222                 pass
00223             winsound.PlaySound(None, winsound.SND_PURGE)
00224         else:
00225             # Issue 8367: PlaySound(None, winsound.SND_PURGE)
00226             # does not raise on systems without a sound card.
00227             pass
00228 

Here is the call graph for this function:


The documentation for this class was generated from the following file: