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
vision
Commits
bce17fdd
Commit
bce17fdd
authored
Dec 16, 2019
by
Oana Florescu
Committed by
Francisco Massa
Dec 16, 2019
Browse files
fixed test for windows by closing the created temporary files (#1662)
parent
757ecfb0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
test/test_io.py
test/test_io.py
+6
-2
No files found.
test/test_io.py
View file @
bce17fdd
...
@@ -58,14 +58,14 @@ def temp_video(num_frames, height, width, fps, lossless=False, video_codec=None,
...
@@ -58,14 +58,14 @@ def temp_video(num_frames, height, width, fps, lossless=False, video_codec=None,
data
=
_create_video_frames
(
num_frames
,
height
,
width
)
data
=
_create_video_frames
(
num_frames
,
height
,
width
)
with
tempfile
.
NamedTemporaryFile
(
suffix
=
'.mp4'
)
as
f
:
with
tempfile
.
NamedTemporaryFile
(
suffix
=
'.mp4'
)
as
f
:
f
.
close
()
io
.
write_video
(
f
.
name
,
data
,
fps
=
fps
,
video_codec
=
video_codec
,
options
=
options
)
io
.
write_video
(
f
.
name
,
data
,
fps
=
fps
,
video_codec
=
video_codec
,
options
=
options
)
yield
f
.
name
,
data
yield
f
.
name
,
data
os
.
unlink
(
f
.
name
)
@
unittest
.
skipIf
(
get_video_backend
()
!=
"pyav"
and
not
io
.
_HAS_VIDEO_OPT
,
@
unittest
.
skipIf
(
get_video_backend
()
!=
"pyav"
and
not
io
.
_HAS_VIDEO_OPT
,
"video_reader backend not available"
)
"video_reader backend not available"
)
@
unittest
.
skipIf
(
av
is
None
,
"PyAV unavailable"
)
@
unittest
.
skipIf
(
av
is
None
,
"PyAV unavailable"
)
@
unittest
.
skipIf
(
sys
.
platform
==
'win32'
,
'temporarily disabled on Windows'
)
class
Tester
(
unittest
.
TestCase
):
class
Tester
(
unittest
.
TestCase
):
# compression adds artifacts, thus we add a tolerance of
# compression adds artifacts, thus we add a tolerance of
# 6 in 0-255 range
# 6 in 0-255 range
...
@@ -106,6 +106,7 @@ class Tester(unittest.TestCase):
...
@@ -106,6 +106,7 @@ class Tester(unittest.TestCase):
expected_pts
=
[
i
*
pts_step
for
i
in
range
(
num_frames
)]
expected_pts
=
[
i
*
pts_step
for
i
in
range
(
num_frames
)]
self
.
assertEqual
(
pts
,
expected_pts
)
self
.
assertEqual
(
pts
,
expected_pts
)
container
.
close
()
def
test_read_partial_video
(
self
):
def
test_read_partial_video
(
self
):
with
temp_video
(
10
,
300
,
300
,
5
,
lossless
=
True
)
as
(
f_name
,
data
):
with
temp_video
(
10
,
300
,
300
,
5
,
lossless
=
True
)
as
(
f_name
,
data
):
...
@@ -176,6 +177,7 @@ class Tester(unittest.TestCase):
...
@@ -176,6 +177,7 @@ class Tester(unittest.TestCase):
expected_pts
=
[
i
*
pts_step
for
i
in
range
(
num_frames
)]
expected_pts
=
[
i
*
pts_step
for
i
in
range
(
num_frames
)]
self
.
assertEqual
(
pts
,
expected_pts
)
self
.
assertEqual
(
pts
,
expected_pts
)
container
.
close
()
def
test_read_video_pts_unit_sec
(
self
):
def
test_read_video_pts_unit_sec
(
self
):
with
temp_video
(
10
,
300
,
300
,
5
,
lossless
=
True
)
as
(
f_name
,
data
):
with
temp_video
(
10
,
300
,
300
,
5
,
lossless
=
True
)
as
(
f_name
,
data
):
...
@@ -196,6 +198,7 @@ class Tester(unittest.TestCase):
...
@@ -196,6 +198,7 @@ class Tester(unittest.TestCase):
expected_pts
=
[
i
*
pts_step
*
stream
.
time_base
for
i
in
range
(
num_frames
)]
expected_pts
=
[
i
*
pts_step
*
stream
.
time_base
for
i
in
range
(
num_frames
)]
self
.
assertEqual
(
pts
,
expected_pts
)
self
.
assertEqual
(
pts
,
expected_pts
)
container
.
close
()
def
test_read_partial_video_pts_unit_sec
(
self
):
def
test_read_partial_video_pts_unit_sec
(
self
):
with
temp_video
(
10
,
300
,
300
,
5
,
lossless
=
True
)
as
(
f_name
,
data
):
with
temp_video
(
10
,
300
,
300
,
5
,
lossless
=
True
)
as
(
f_name
,
data
):
...
@@ -218,6 +221,7 @@ class Tester(unittest.TestCase):
...
@@ -218,6 +221,7 @@ class Tester(unittest.TestCase):
# when the given start pts is not matching any frame pts
# when the given start pts is not matching any frame pts
self
.
assertEqual
(
len
(
lv
),
4
)
self
.
assertEqual
(
len
(
lv
),
4
)
self
.
assertTrue
(
data
[
4
:
8
].
equal
(
lv
))
self
.
assertTrue
(
data
[
4
:
8
].
equal
(
lv
))
container
.
close
()
def
test_read_video_corrupted_file
(
self
):
def
test_read_video_corrupted_file
(
self
):
with
tempfile
.
NamedTemporaryFile
(
suffix
=
'.mp4'
)
as
f
:
with
tempfile
.
NamedTemporaryFile
(
suffix
=
'.mp4'
)
as
f
:
...
...
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