Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4d16b915
Commit
4d16b915
authored
Jul 25, 2006
by
Greg Ward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use standard assert: want tests to fail even when run with -O.
Delete cruft.
parent
0bbfd832
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
+17
-15
Lib/test/test_ossaudiodev.py
Lib/test/test_ossaudiodev.py
+17
-15
No files found.
Lib/test/test_ossaudiodev.py
View file @
4d16b915
...
...
@@ -40,6 +40,10 @@ def read_sound_file(path):
data
=
audioop
.
ulaw2lin
(
data
,
2
)
return
(
data
,
rate
,
16
,
nchannels
)
# version of assert that still works with -O
def
_assert
(
expr
,
message
=
None
):
if
not
expr
:
raise
AssertionError
(
message
or
"assertion failed"
)
def
play_sound_file
(
data
,
rate
,
ssize
,
nchannels
):
try
:
...
...
@@ -57,9 +61,9 @@ def play_sound_file(data, rate, ssize, nchannels):
dsp
.
fileno
()
# Make sure the read-only attributes work.
assert
dsp
.
closed
is
False
,
"dsp.closed is not False"
assert
dsp
.
name
==
"/dev/dsp"
assert
dsp
.
mode
==
'w'
,
"bad dsp.mode: %r"
%
dsp
.
mode
_assert
(
dsp
.
closed
is
False
,
"dsp.closed is not False"
)
_assert
(
dsp
.
name
==
"/dev/dsp"
)
_assert
(
dsp
.
mode
==
'w'
,
"bad dsp.mode: %r"
%
dsp
.
mode
)
# And make sure they're really read-only.
for
attr
in
(
'closed'
,
'name'
,
'mode'
):
...
...
@@ -83,11 +87,9 @@ def play_sound_file(data, rate, ssize, nchannels):
elapsed_time
=
t2
-
t1
percent_diff
=
(
abs
(
elapsed_time
-
expected_time
)
/
expected_time
)
*
100
#print ("actual running time was %.2f sec (%.1f%% difference)"
# % (elapsed_time, percent_diff))
assert
percent_diff
<=
10.0
,
\
(
"elapsed time (%.2f sec) > 10%% off of expected time (%.2f sec)"
%
(
elapsed_time
,
expected_time
))
_assert
(
percent_diff
<=
10.0
,
\
(
"elapsed time (%.2f sec) > 10%% off of expected time (%.2f sec)"
%
(
elapsed_time
,
expected_time
)))
def
test_setparameters
(
dsp
):
# Two configurations for testing:
...
...
@@ -112,11 +114,11 @@ def test_setparameters(dsp):
# setparameters() should be able to set this configuration in
# either strict or non-strict mode.
result
=
dsp
.
setparameters
(
fmt
,
channels
,
rate
,
False
)
assert
result
==
(
fmt
,
channels
,
rate
),
\
"setparameters%r: returned %r"
%
(
config
+
result
)
_assert
(
result
==
(
fmt
,
channels
,
rate
),
"setparameters%r: returned %r"
%
(
config
+
result
)
)
result
=
dsp
.
setparameters
(
fmt
,
channels
,
rate
,
True
)
assert
result
==
(
fmt
,
channels
,
rate
),
\
"setparameters%r: returned %r"
%
(
config
+
result
)
_assert
(
result
==
(
fmt
,
channels
,
rate
),
"setparameters%r: returned %r"
%
(
config
+
result
)
)
def
test_bad_setparameters
(
dsp
):
...
...
@@ -134,8 +136,8 @@ def test_bad_setparameters(dsp):
]:
(
fmt
,
channels
,
rate
)
=
config
result
=
dsp
.
setparameters
(
fmt
,
channels
,
rate
,
False
)
assert
result
!=
config
,
\
"setparameters: unexpectedly got requested configuration"
_assert
(
result
!=
config
,
"setparameters: unexpectedly got requested configuration"
)
try
:
result
=
dsp
.
setparameters
(
fmt
,
channels
,
rate
,
True
)
...
...
@@ -156,6 +158,6 @@ def test():
#test_bad_setparameters(dsp)
finally
:
dsp
.
close
()
assert
dsp
.
closed
is
True
,
"dsp.closed is not True"
_assert
(
dsp
.
closed
is
True
,
"dsp.closed is not True"
)
test
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment