From 5ee4fa447d9ae4161c2fdca313584ee0e5d66721 Mon Sep 17 00:00:00 2001
From: Stuart Prescott <stuart@debian.org>
Date: Sat, 7 Nov 2026 01:06:45 +1100
Subject: [PATCH] Run tests against all supported Python versions

---
 debian/pybuild.testfiles |  2 ++
 debian/rules             | 15 +++------------
 2 files changed, 5 insertions(+), 12 deletions(-)
 create mode 100644 debian/pybuild.testfiles

diff --git a/debian/pybuild.testfiles b/debian/pybuild.testfiles
new file mode 100644
index 0000000..953d922
--- /dev/null
+++ b/debian/pybuild.testfiles
@@ -0,0 +1,2 @@
+tools
+tests
diff --git a/debian/rules b/debian/rules
index 6f65fa4..5fdd415 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,6 +1,9 @@
 #!/usr/bin/make -f
 
 export PYBUILD_NAME=geoalchemy2
+export PYBUILD_TEST_CUSTOM = 1
+export PYBUILD_TEST_ARGS = {interpreter} $(CURDIR)/debian/tests/setup-db-and-run-tests.py
+
 %:
 	dh $@ --buildsystem=pybuild
 
@@ -8,13 +11,6 @@ override_dh_auto_clean:
 	dh_auto_clean
 	rm -rf GeoAlchemy2.egg-info .pytest_cache doc/gallery
 
-override_dh_auto_test:
-ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
-	$(eval BUILD_DIR=$(shell pybuild --print '{build_dir}'))
-	for build_dir in $(BUILD_DIR); do cp -r tests $$build_dir; done
-	python3 $(CURDIR)/debian/tests/setup-db-and-run-tests.py
-endif
-
 override_dh_installdocs:
 	dh_installdocs --doc-main-package=python3-geoalchemy2 -p python-geoalchemy2-doc
 	dh_installdocs -p python3-geoalchemy2
@@ -30,8 +26,3 @@ ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
 	done
 	rm -rf doc/gallery
 endif
-
-override_dh_install:
-	dh_install
-	find debian/python3-geoalchemy2/usr/lib -type d \( -name dist-packages -o -name site-packages \) \
-	    -exec rm -rf '{}/build' '{}/tests' \;
-- 
2.47.3

