From d140c593ba9f4ba23ff886e74f166d1f85ec7b9c Mon Sep 17 00:00:00 2001 From: Mitch Burton Date: Tue, 20 Aug 2024 09:05:22 -0700 Subject: [PATCH] fix: patch missing Trial addDuration method in py312 (#253) --- Makefile | 2 +- landscape/lib/run_tests.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 landscape/lib/run_tests.py diff --git a/Makefile b/Makefile index 842f946a..7ca4ff9e 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ PYDOCTOR ?= pydoctor TXT2MAN ?= txt2man PYTHON ?= python3 SNAPCRAFT = SNAPCRAFT_BUILD_INFO=1 snapcraft -TRIAL ?= -m twisted.trial +TRIAL ?= -m landscape.lib.run_tests TRIAL_ARGS ?= PRE_COMMIT ?= $(HOME)/.local/bin/pre-commit diff --git a/landscape/lib/run_tests.py b/landscape/lib/run_tests.py new file mode 100644 index 00000000..074cb994 --- /dev/null +++ b/landscape/lib/run_tests.py @@ -0,0 +1,15 @@ +if __name__ == "__main__": + # Patch Twisted Trial's `_AdaptedReporter` to add the Python 3.12-expected + # `addDuration` method. This eliminates a large amount of emitted warnings, + # and should no longer be necessary once + # https://github.com/twisted/twisted/issues/12229 is fixed. + import sys + from twisted.trial.reporter import _AdaptedReporter + from twisted.scripts.trial import run + + def _addDuration(self, _test, _elapsed): + pass + + _AdaptedReporter.addDuration = _addDuration + + sys.exit(run())