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
0f457e58
Commit
0f457e58
authored
Apr 29, 2009
by
R. David Murray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More aifc tests.
parent
61dbdb96
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
7 deletions
+53
-7
Lib/test/test_aifc.py
Lib/test/test_aifc.py
+53
-7
No files found.
Lib/test/test_aifc.py
View file @
0f457e58
from
test.test_support
import
findfile
,
run_unittest
from
test.test_support
import
findfile
,
run_unittest
,
TESTFN
import
unittest
import
unittest
import
os
import
aifc
import
aifc
...
@@ -7,16 +8,29 @@ import aifc
...
@@ -7,16 +8,29 @@ import aifc
class
AIFCTest
(
unittest
.
TestCase
):
class
AIFCTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
f
=
self
.
fout
=
None
self
.
sndfilepath
=
findfile
(
'Sine-1000Hz-300ms.aif'
)
self
.
sndfilepath
=
findfile
(
'Sine-1000Hz-300ms.aif'
)
def
tearDown
(
self
):
if
self
.
f
is
not
None
:
self
.
f
.
close
()
if
self
.
fout
is
not
None
:
try
:
self
.
fout
.
close
()
except
(
aifc
.
Error
,
AttributeError
):
pass
try
:
os
.
remove
(
TESTFN
)
except
OSError
:
pass
def
test_skipunknown
(
self
):
def
test_skipunknown
(
self
):
#Issue 2245
#Issue 2245
#This file contains chunk types aifc doesn't recognize.
#This file contains chunk types aifc doesn't recognize.
f
=
aifc
.
open
(
self
.
sndfilepath
)
f
=
aifc
.
open
(
self
.
sndfilepath
)
f
.
close
()
def
test_params
(
self
):
def
test_params
(
self
):
f
=
aifc
.
open
(
self
.
sndfilepath
)
f
=
self
.
f
=
aifc
.
open
(
self
.
sndfilepath
)
self
.
assertEqual
(
f
.
getnchannels
(),
2
)
self
.
assertEqual
(
f
.
getnchannels
(),
2
)
self
.
assertEqual
(
f
.
getsampwidth
(),
2
)
self
.
assertEqual
(
f
.
getsampwidth
(),
2
)
self
.
assertEqual
(
f
.
getframerate
(),
48000
)
self
.
assertEqual
(
f
.
getframerate
(),
48000
)
...
@@ -24,10 +38,9 @@ class AIFCTest(unittest.TestCase):
...
@@ -24,10 +38,9 @@ class AIFCTest(unittest.TestCase):
self
.
assertEqual
(
f
.
getcomptype
(),
'NONE'
)
self
.
assertEqual
(
f
.
getcomptype
(),
'NONE'
)
self
.
assertEqual
(
f
.
getcompname
(),
'not compressed'
)
self
.
assertEqual
(
f
.
getcompname
(),
'not compressed'
)
self
.
assertEqual
(
f
.
getparams
(),
(
2
,
2
,
48000
,
14400
,
'NONE'
,
'not compressed'
))
self
.
assertEqual
(
f
.
getparams
(),
(
2
,
2
,
48000
,
14400
,
'NONE'
,
'not compressed'
))
f
.
close
()
def
test_read
(
self
):
def
test_read
(
self
):
f
=
aifc
.
open
(
self
.
sndfilepath
)
f
=
self
.
f
=
aifc
.
open
(
self
.
sndfilepath
)
self
.
assertEqual
(
f
.
tell
(),
0
)
self
.
assertEqual
(
f
.
tell
(),
0
)
self
.
assertEqual
(
f
.
readframes
(
2
),
'
\
x00
\
x00
\
x00
\
x00
\
x0b
\
xd4
\
x0b
\
xd4
'
)
self
.
assertEqual
(
f
.
readframes
(
2
),
'
\
x00
\
x00
\
x00
\
x00
\
x0b
\
xd4
\
x0b
\
xd4
'
)
f
.
rewind
()
f
.
rewind
()
...
@@ -41,9 +54,42 @@ class AIFCTest(unittest.TestCase):
...
@@ -41,9 +54,42 @@ class AIFCTest(unittest.TestCase):
self
.
assertEqual
(
f
.
readframes
(
2
),
'
\
x17
t
\
x17
t"
\
xad
"
\
xad
'
)
self
.
assertEqual
(
f
.
readframes
(
2
),
'
\
x17
t
\
x17
t"
\
xad
"
\
xad
'
)
f
.
setpos
(
pos0
)
f
.
setpos
(
pos0
)
self
.
assertEqual
(
f
.
readframes
(
2
),
'
\
x00
\
x00
\
x00
\
x00
\
x0b
\
xd4
\
x0b
\
xd4
'
)
self
.
assertEqual
(
f
.
readframes
(
2
),
'
\
x00
\
x00
\
x00
\
x00
\
x0b
\
xd4
\
x0b
\
xd4
'
)
f
.
close
()
#XXX Need more tests!
def
test_write
(
self
):
f
=
self
.
f
=
aifc
.
open
(
self
.
sndfilepath
)
fout
=
self
.
fout
=
aifc
.
open
(
TESTFN
,
'wb'
)
fout
.
aifc
()
fout
.
setparams
(
f
.
getparams
())
for
frame
in
range
(
f
.
getnframes
()):
fout
.
writeframes
(
f
.
readframes
(
1
))
fout
.
close
()
fout
=
self
.
fout
=
aifc
.
open
(
TESTFN
,
'rb'
)
f
.
rewind
()
self
.
assertEqual
(
f
.
getparams
(),
fout
.
getparams
())
self
.
assertEqual
(
f
.
readframes
(
5
),
fout
.
readframes
(
5
))
def
test_compress
(
self
):
f
=
self
.
f
=
aifc
.
open
(
self
.
sndfilepath
)
fout
=
self
.
fout
=
aifc
.
open
(
TESTFN
,
'wb'
)
fout
.
aifc
()
fout
.
setnchannels
(
f
.
getnchannels
())
fout
.
setsampwidth
(
f
.
getsampwidth
())
fout
.
setframerate
(
f
.
getframerate
())
fout
.
setcomptype
(
'ULAW'
,
'foo'
)
for
frame
in
range
(
f
.
getnframes
()):
fout
.
writeframes
(
f
.
readframes
(
1
))
fout
.
close
()
self
.
assertLess
(
os
.
stat
(
TESTFN
).
st_size
,
os
.
stat
(
self
.
sndfilepath
).
st_size
*
0.75
,
)
fout
=
self
.
fout
=
aifc
.
open
(
TESTFN
,
'rb'
)
f
.
rewind
()
self
.
assertEqual
(
f
.
getparams
()[
0
:
3
],
fout
.
getparams
()[
0
:
3
])
self
.
assertEqual
(
fout
.
getcomptype
(),
'ULAW'
)
self
.
assertEqual
(
fout
.
getcompname
(),
'foo'
)
# XXX: this test fails, not sure if it should succeed or not
# self.assertEqual(f.readframes(5), fout.readframes(5))
def
test_main
():
def
test_main
():
...
...
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