Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
0f457e58
Kaydet (Commit)
0f457e58
authored
Nis 29, 2009
tarafından
R. David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
More aifc tests.
üst
61dbdb96
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
7 deletions
+53
-7
test_aifc.py
Lib/test/test_aifc.py
+53
-7
No files found.
Lib/test/test_aifc.py
Dosyayı görüntüle @
0f457e58
from
test.test_support
import
findfile
,
run_unittest
from
test.test_support
import
findfile
,
run_unittest
,
TESTFN
import
unittest
import
os
import
aifc
...
...
@@ -7,16 +8,29 @@ import aifc
class
AIFCTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
f
=
self
.
fout
=
None
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
):
#Issue 2245
#This file contains chunk types aifc doesn't recognize.
f
=
aifc
.
open
(
self
.
sndfilepath
)
f
.
close
()
def
test_params
(
self
):
f
=
aifc
.
open
(
self
.
sndfilepath
)
f
=
self
.
f
=
aifc
.
open
(
self
.
sndfilepath
)
self
.
assertEqual
(
f
.
getnchannels
(),
2
)
self
.
assertEqual
(
f
.
getsampwidth
(),
2
)
self
.
assertEqual
(
f
.
getframerate
(),
48000
)
...
...
@@ -24,10 +38,9 @@ class AIFCTest(unittest.TestCase):
self
.
assertEqual
(
f
.
getcomptype
(),
'NONE'
)
self
.
assertEqual
(
f
.
getcompname
(),
'not compressed'
)
self
.
assertEqual
(
f
.
getparams
(),
(
2
,
2
,
48000
,
14400
,
'NONE'
,
'not compressed'
))
f
.
close
()
def
test_read
(
self
):
f
=
aifc
.
open
(
self
.
sndfilepath
)
f
=
self
.
f
=
aifc
.
open
(
self
.
sndfilepath
)
self
.
assertEqual
(
f
.
tell
(),
0
)
self
.
assertEqual
(
f
.
readframes
(
2
),
'
\x00\x00\x00\x00\x0b\xd4\x0b\xd4
'
)
f
.
rewind
()
...
...
@@ -41,9 +54,42 @@ class AIFCTest(unittest.TestCase):
self
.
assertEqual
(
f
.
readframes
(
2
),
'
\x17
t
\x17
t"
\xad
"
\xad
'
)
f
.
setpos
(
pos0
)
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
():
...
...
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