Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ccc9ef7

Browse files
committed
attempt to fix win runner
1 parent 2f7d0fa commit ccc9ef7

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

.github/workflows/test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,15 @@ jobs:
4949
python-version: ${{ matrix.python-version }}
5050
- name: Install Cairo (Ubuntu)
5151
if: matrix.platform == 'ubuntu-latest'
52-
run: sudo apt-get install libcairo2-dev ffmpeg
52+
run: sudo apt-get install libcairo2-dev
53+
- name: Install ffmpeg (Ubuntu)
54+
if: matrix.platform == 'ubuntu-latest'
55+
run: sudo apt-get install ffmpeg
56+
- name: Install ffmpeg (Windows)
57+
if: matrix.platform == 'windows-latest'
58+
run: choco install ffmpeg -y
59+
shell: pwsh
60+
5361
- name: Install packages
5462
run: |
5563
pip install '.[qa]'

Lib/gftools/scripts/fix_media.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def remove_unused_media(fp: Path, article: BeautifulSoup):
106106

107107

108108
def fix_media(fp: Path, out: Path = None, inplace: bool = False, dry_run: bool = False):
109-
shutil.rmtree(out, ignore_errors=True)
109+
if out.exists():
110+
shutil.rmtree(out)
110111
os.makedirs(out)
111112

112113
# Work on a copy of every file so we can do a dry run if needed.

tests/test_fix_media.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pathlib import Path
77

88

9-
TEST_DATA = os.path.join("data", "test", "article")
9+
TEST_DATA = Path(os.path.join("data", "test", "article"))
1010

1111

1212
def test_fix_media():
@@ -17,15 +17,20 @@ def test_fix_media():
1717
out=tmp_dir,
1818
)
1919
# width should be 1024
20-
img = Image.open(os.path.join(tmp_dir, "img1.jpg"))
20+
img_path = tmp_dir / "img1.jpg"
21+
img = Image.open(img_path)
2122
img_width, img_height = img.size
2223
assert img_width <= MAX_WIDTH
2324
assert img_height <= MAX_HEIGHT
2425

2526
# Filesize should be less than 800kb
26-
img_size = os.stat(tmp_dir / "img1.jpg").st_size
27+
img_size = os.stat(img_path).st_size
2728
assert img_size <= MAXSIZE_RASTER
2829

2930
# Check gif is converted to mp4
30-
assert (tmp_dir / "vid1.mp4").exists()
31-
assert not (tmp_dir / "vid1.gif").exists()
31+
vid_path = tmp_dir / "vid1.mp4"
32+
assert (vid_path).exists()
33+
# Check olf gif is deleted
34+
old_gif = tmp_dir / "vid1.gif"
35+
assert not (old_gif).exists()
36+
img.close()

0 commit comments

Comments
 (0)