Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
cdf5c83d
Commit
cdf5c83d
authored
Jan 02, 2020
by
Karl Ostmo
Committed by
Vincent QB
Jan 02, 2020
Browse files
conditionally skip unsupported subTest tests for Python 2 (#386)
closes #387
parent
479e666b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
test/test.py
test/test.py
+9
-0
No files found.
test/test.py
View file @
cdf5c83d
...
@@ -5,6 +5,7 @@ import torch
...
@@ -5,6 +5,7 @@ import torch
import
torchaudio
import
torchaudio
import
math
import
math
import
os
import
os
import
sys
class
AudioBackendScope
:
class
AudioBackendScope
:
...
@@ -28,6 +29,7 @@ class Test_LoadSave(unittest.TestCase):
...
@@ -28,6 +29,7 @@ class Test_LoadSave(unittest.TestCase):
test_filepath_wav
=
os
.
path
.
join
(
test_dirpath
,
"assets"
,
test_filepath_wav
=
os
.
path
.
join
(
test_dirpath
,
"assets"
,
"steam-train-whistle-daniel_simon.wav"
)
"steam-train-whistle-daniel_simon.wav"
)
@
unittest
.
skipIf
(
sys
.
version_info
<
(
3
,
4
),
"subTest unavailable for this Python version"
)
def
test_1_save
(
self
):
def
test_1_save
(
self
):
for
backend
in
[
"sox"
]:
for
backend
in
[
"sox"
]:
with
self
.
subTest
():
with
self
.
subTest
():
...
@@ -79,6 +81,7 @@ class Test_LoadSave(unittest.TestCase):
...
@@ -79,6 +81,7 @@ class Test_LoadSave(unittest.TestCase):
"test.wav"
)
"test.wav"
)
torchaudio
.
save
(
new_filepath
,
x
,
sr
)
torchaudio
.
save
(
new_filepath
,
x
,
sr
)
@
unittest
.
skipIf
(
sys
.
version_info
<
(
3
,
4
),
"subTest unavailable for this Python version"
)
def
test_1_save_sine
(
self
):
def
test_1_save_sine
(
self
):
for
backend
in
[
"sox"
,
"soundfile"
]:
for
backend
in
[
"sox"
,
"soundfile"
]:
with
self
.
subTest
():
with
self
.
subTest
():
...
@@ -112,6 +115,7 @@ class Test_LoadSave(unittest.TestCase):
...
@@ -112,6 +115,7 @@ class Test_LoadSave(unittest.TestCase):
self
.
assertEqual
(
si32
.
precision
,
new_precision
)
self
.
assertEqual
(
si32
.
precision
,
new_precision
)
os
.
unlink
(
new_filepath
)
os
.
unlink
(
new_filepath
)
@
unittest
.
skipIf
(
sys
.
version_info
<
(
3
,
4
),
"subTest unavailable for this Python version"
)
def
test_2_load
(
self
):
def
test_2_load
(
self
):
for
backend
in
[
"sox"
]:
for
backend
in
[
"sox"
]:
with
self
.
subTest
():
with
self
.
subTest
():
...
@@ -153,6 +157,7 @@ class Test_LoadSave(unittest.TestCase):
...
@@ -153,6 +157,7 @@ class Test_LoadSave(unittest.TestCase):
os
.
path
.
dirname
(
self
.
test_dirpath
),
"torchaudio"
)
os
.
path
.
dirname
(
self
.
test_dirpath
),
"torchaudio"
)
torchaudio
.
load
(
tdir
)
torchaudio
.
load
(
tdir
)
@
unittest
.
skipIf
(
sys
.
version_info
<
(
3
,
4
),
"subTest unavailable for this Python version"
)
def
test_2_load_nonormalization
(
self
):
def
test_2_load_nonormalization
(
self
):
for
backend
in
[
"sox"
]:
for
backend
in
[
"sox"
]:
with
self
.
subTest
():
with
self
.
subTest
():
...
@@ -170,6 +175,7 @@ class Test_LoadSave(unittest.TestCase):
...
@@ -170,6 +175,7 @@ class Test_LoadSave(unittest.TestCase):
x
,
_
=
torchaudio
.
load
(
test_filepath
,
torch
.
LongTensor
(),
normalization
=
False
)
x
,
_
=
torchaudio
.
load
(
test_filepath
,
torch
.
LongTensor
(),
normalization
=
False
)
self
.
assertTrue
(
isinstance
(
x
,
torch
.
LongTensor
))
self
.
assertTrue
(
isinstance
(
x
,
torch
.
LongTensor
))
@
unittest
.
skipIf
(
sys
.
version_info
<
(
3
,
4
),
"subTest unavailable for this Python version"
)
def
test_3_load_and_save_is_identity
(
self
):
def
test_3_load_and_save_is_identity
(
self
):
for
backend
in
[
"sox"
,
"soundfile"
]:
for
backend
in
[
"sox"
,
"soundfile"
]:
with
self
.
subTest
():
with
self
.
subTest
():
...
@@ -186,6 +192,7 @@ class Test_LoadSave(unittest.TestCase):
...
@@ -186,6 +192,7 @@ class Test_LoadSave(unittest.TestCase):
self
.
assertEqual
(
sample_rate
,
sample_rate2
)
self
.
assertEqual
(
sample_rate
,
sample_rate2
)
os
.
unlink
(
output_path
)
os
.
unlink
(
output_path
)
@
unittest
.
skipIf
(
sys
.
version_info
<
(
3
,
4
),
"subTest unavailable for this Python version"
)
def
test_3_load_and_save_is_identity_across_backend
(
self
):
def
test_3_load_and_save_is_identity_across_backend
(
self
):
with
self
.
subTest
():
with
self
.
subTest
():
self
.
_test_3_load_and_save_is_identity_across_backend
(
"sox"
,
"soundfile"
)
self
.
_test_3_load_and_save_is_identity_across_backend
(
"sox"
,
"soundfile"
)
...
@@ -208,6 +215,7 @@ class Test_LoadSave(unittest.TestCase):
...
@@ -208,6 +215,7 @@ class Test_LoadSave(unittest.TestCase):
self
.
assertEqual
(
sample_rate1
,
sample_rate2
)
self
.
assertEqual
(
sample_rate1
,
sample_rate2
)
os
.
unlink
(
output_path
)
os
.
unlink
(
output_path
)
@
unittest
.
skipIf
(
sys
.
version_info
<
(
3
,
4
),
"subTest unavailable for this Python version"
)
def
test_4_load_partial
(
self
):
def
test_4_load_partial
(
self
):
for
backend
in
[
"sox"
]:
for
backend
in
[
"sox"
]:
with
self
.
subTest
():
with
self
.
subTest
():
...
@@ -250,6 +258,7 @@ class Test_LoadSave(unittest.TestCase):
...
@@ -250,6 +258,7 @@ class Test_LoadSave(unittest.TestCase):
with
self
.
assertRaises
(
RuntimeError
):
with
self
.
assertRaises
(
RuntimeError
):
torchaudio
.
load
(
input_sine_path
,
offset
=
100000
)
torchaudio
.
load
(
input_sine_path
,
offset
=
100000
)
@
unittest
.
skipIf
(
sys
.
version_info
<
(
3
,
4
),
"subTest unavailable for this Python version"
)
def
test_5_get_info
(
self
):
def
test_5_get_info
(
self
):
for
backend
in
[
"sox"
,
"soundfile"
]:
for
backend
in
[
"sox"
,
"soundfile"
]:
with
self
.
subTest
():
with
self
.
subTest
():
...
...
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