Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed test for windows by closing the created temporary files #1662

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
with tempfile.NamedTemporaryFile(suffix='.mp4') as f:
f.close()
io.write_video(f.name, data, fps=fps, video_codec=video_codec, options=options)
yield f.name, data

os.unlink(f.name)

@unittest.skipIf(get_video_backend() != "pyav" and not io._HAS_VIDEO_OPT,
"video_reader backend not available")
@unittest.skipIf(av is None, "PyAV unavailable")
@unittest.skipIf(sys.platform == 'win32', 'temporarily disabled on Windows')
class Tester(unittest.TestCase):
# compression adds artifacts, thus we add a tolerance of
# 6 in 0-255 range
Expand Down Expand Up @@ -106,6 +106,7 @@ def test_read_timestamps(self):
expected_pts = [i * pts_step for i in range(num_frames)]

self.assertEqual(pts, expected_pts)
container.close()

def test_read_partial_video(self):
with temp_video(10, 300, 300, 5, lossless=True) as (f_name, data):
Expand Down Expand Up @@ -176,6 +177,7 @@ def test_read_timestamps_from_packet(self):
expected_pts = [i * pts_step for i in range(num_frames)]

self.assertEqual(pts, expected_pts)
container.close()

def test_read_video_pts_unit_sec(self):
with temp_video(10, 300, 300, 5, lossless=True) as (f_name, data):
Expand All @@ -196,6 +198,7 @@ def test_read_timestamps_pts_unit_sec(self):
expected_pts = [i * pts_step * stream.time_base for i in range(num_frames)]

self.assertEqual(pts, expected_pts)
container.close()

def test_read_partial_video_pts_unit_sec(self):
with temp_video(10, 300, 300, 5, lossless=True) as (f_name, data):
Expand All @@ -218,6 +221,7 @@ def test_read_partial_video_pts_unit_sec(self):
# when the given start pts is not matching any frame pts
self.assertEqual(len(lv), 4)
self.assertTrue(data[4:8].equal(lv))
container.close()

def test_read_video_corrupted_file(self):
with tempfile.NamedTemporaryFile(suffix='.mp4') as f:
Expand Down