Skip to content

Commit

Permalink
Ignore threading problems cleaning files in tests under Windows (Zulk…
Browse files Browse the repository at this point in the history
…o#1644)

* Fix threading issues removing files in tests under Windows
  • Loading branch information
mondeja authored Aug 18, 2021
1 parent 52b0a86 commit d46941e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
5 changes: 4 additions & 1 deletion tests/test_VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ def test_write_videofiles_with_temp_audiofile_path(util):
def test_save_frame(util, with_mask, t, mask_color, frames):
filename = os.path.join(util.TMP_DIR, "moviepy_VideoClip_save_frame.png")
if os.path.isfile(filename):
os.remove(filename)
try:
os.remove(filename)
except PermissionError:
pass

width, height = (len(frames[0][0]), len(frames[0]))

Expand Down
10 changes: 8 additions & 2 deletions tests/test_ffmpeg_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ def test_ffmpeg_write_video(
def test_ffmpeg_write_image(util, size, logfile, pixel_format, expected_result):
filename = os.path.join(util.TMP_DIR, "moviepy_ffmpeg_write_image.png")
if os.path.isfile(filename):
os.remove(filename)
try:
os.remove(filename)
except PermissionError:
pass

image_array = color_gradient(
size,
Expand Down Expand Up @@ -192,7 +195,10 @@ def test_ffmpeg_write_image(util, size, logfile, pixel_format, expected_result):
def test_write_gif(util, clip_class, opt, loop, with_mask, pixel_format):
filename = os.path.join(util.TMP_DIR, "moviepy_write_gif.gif")
if os.path.isfile(filename):
os.remove(filename)
try:
os.remove(filename)
except PermissionError:
pass

fps = 10

Expand Down
10 changes: 8 additions & 2 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ def to_file(*args, **kwargs):
def test_download_webfile(static_files_server, util, url, expected_result):
filename = os.path.join(util.TMP_DIR, "moviepy_downloader_test.mp4")
if os.path.isfile(filename):
os.remove(filename)
try:
os.remove(filename)
except PermissionError:
pass

if hasattr(expected_result, "__traceback__") or len(url) == 11:
if not shutil.which("youtube-dl"):
Expand All @@ -132,7 +135,10 @@ def test_download_webfile(static_files_server, util, url, expected_result):
assert filecmp.cmp(filename, expected_result)

if os.path.isfile(filename):
os.remove(filename)
try:
os.remove(filename)
except PermissionError:
pass


@pytest.mark.skipif(os.name != "posix", reason="Doesn't works in Windows")
Expand Down
5 changes: 4 additions & 1 deletion tests/test_videotools.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,10 @@ def test_Trajectory_addy():
def test_Trajectory_from_to_file(util):
filename = os.path.join(util.TMP_DIR, "moviepy_Trajectory_from_to_file.txt")
if os.path.isfile(filename):
os.remove(filename)
try:
os.remove(filename)
except PermissionError:
pass

trajectory_file_content = """# t(ms) x y
0 554 100
Expand Down

0 comments on commit d46941e

Please sign in to comment.