Skip to main content

Parallelise the test_no_videos_are_av1 test

ID
8d5fb3a
date
2025-12-10 23:25:43+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
8476cf4
message
Parallelise the `test_no_videos_are_av1` test
changed files
3 files, 16 additions, 6 deletions

Changed files

CHANGELOG.md (2270) → CHANGELOG.md (2392)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4a117e0..3bdee38 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
 # CHANGELOG
 
+## v20 - 2025-12-10
+
+Use concurrency in `test_no_videos_are_av1`, which can make it faster for
+larger media collections.
+
 ## v19 - 2025-12-09
 
 Allow passing both `width` and `height` as part of `ThumbnailConfig`, to constrain a thumbnail to a bounding box.

src/chives/__init__.py (391) → src/chives/__init__.py (391)

diff --git a/src/chives/__init__.py b/src/chives/__init__.py
index 10699f4..815e16a 100644
--- a/src/chives/__init__.py
+++ b/src/chives/__init__.py
@@ -11,4 +11,4 @@ I share across multiple sites.
 
 """
 
-__version__ = "19"
+__version__ = "20"

src/chives/static_site_tests.py (7213) → src/chives/static_site_tests.py (7443)

diff --git a/src/chives/static_site_tests.py b/src/chives/static_site_tests.py
index e66722f..5373f33 100644
--- a/src/chives/static_site_tests.py
+++ b/src/chives/static_site_tests.py
@@ -5,6 +5,7 @@ Defines a set of common tests and test helpers used for all my static sites.
 from abc import ABC, abstractmethod
 import collections
 from collections.abc import Iterator
+import concurrent.futures
 import glob
 import itertools
 import os
@@ -178,11 +179,15 @@ class StaticSiteTestSuite[M](ABC):
         """
         av1_videos = set()
 
-        av1_videos = {
-            p
-            for p in glob.glob("**/*.mp4", root_dir=site_root, recursive=True)
-            if is_av1_video(site_root / p)
-        }
+        with concurrent.futures.ThreadPoolExecutor() as executor:
+            futures = {
+                executor.submit(is_av1_video, site_root / p): p
+                for p in glob.glob("**/*.mp4", root_dir=site_root, recursive=True)
+            }
+
+            concurrent.futures.wait(futures)
+
+            av1_videos = {p for fut, p in futures.items() if fut.result()}
 
         assert av1_videos == set(), f"Found videos encoded with AV1: {av1_videos}"