From 64fc77043b771169a16301828464cb5f29edb8a8 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Sat, 28 Feb 2026 11:40:53 +0000 Subject: [PATCH 1/2] Remove scripts/all-pythons We can use tox for this nowadays. Signed-off-by: Stephen Finucane --- scripts/all-pythons | 93 --------------------------------------------- 1 file changed, 93 deletions(-) delete mode 100755 scripts/all-pythons diff --git a/scripts/all-pythons b/scripts/all-pythons deleted file mode 100755 index 96b156b0..00000000 --- a/scripts/all-pythons +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/python - -"""Run the testtools test suite for all supported Pythons. - -Prints output as a subunit test suite. If anything goes to stderr, that is -treated as a test error. If a Python is not available, then it is skipped. -""" - -from datetime import datetime -import io -import os -import subprocess -import sys - -import subunit -from subunit import ( - iso8601, - _make_stream_binary, - TestProtocolClient, - TestProtocolServer, - ) -from testtools import ( - PlaceHolder, - TestCase, - ) -from testtools.content import text_content - - -ROOT = os.path.dirname(os.path.dirname(__file__)) - - -def run_for_python(version, result, tests): - if not tests: - tests = ['tests.test_suite'] - # XXX: This could probably be broken up and put into subunit. - python = 'python%s' % (version,) - # XXX: Correct API, but subunit doesn't support it. :( - # result.tags(set(python), set()) - result.time(now()) - test = PlaceHolder(''.join(c for c in python if c != '.')) - process = subprocess.Popen( - '%s -c pass' % (python,), shell=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - process.communicate() - - if process.returncode: - result.startTest(test) - result.addSkip(test, reason='%s not available' % (python,)) - result.stopTest(test) - return - - env = os.environ.copy() - if env.get('PYTHONPATH', None): - env['PYTHONPATH'] = os.pathsep.join([ROOT, env['PYTHONPATH']]) - else: - env['PYTHONPATH'] = ROOT - result.time(now()) - protocol = TestProtocolServer(result) - subunit_path = os.path.join(os.path.dirname(subunit.__file__), 'run.py') - cmd = [ - python, - '-W', 'ignore:Module testtools was already imported', - subunit_path] - cmd.extend(tests) - process = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) - _make_stream_binary(process.stdout) - _make_stream_binary(process.stderr) - # XXX: This buffers everything. Bad for memory, bad for getting progress - # on jenkins. - output, error = process.communicate() - protocol.readFrom(io.BytesIO(output)) - if error: - result.startTest(test) - result.addError(test, details={ - 'stderr': text_content(error), - }) - result.stopTest(test) - result.time(now()) - # XXX: Correct API, but subunit doesn't support it. :( - #result.tags(set(), set(python)) - - -def now(): - return datetime.now(tz=iso8601.Utc()) - - - -if __name__ == '__main__': - sys.path.append(ROOT) - result = TestProtocolClient(sys.stdout) - for version in '3.10 3.11 3.12 3.13 3.14'.split(): - run_for_python(version, result, sys.argv[1:]) From 9b7798939a7ab200a090f7b51533f1305c6d5ab7 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Sat, 28 Feb 2026 09:43:56 +0000 Subject: [PATCH 2/2] Add pre-commit Signed-off-by: Stephen Finucane --- .pre-commit-config.yaml | 19 +++++++++++++++++++ scripts/update-rtfd | 7 +++---- testtools/run.py | 0 tox.ini | 5 ++--- 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 .pre-commit-config.yaml mode change 100755 => 100644 testtools/run.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..1fa73453 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,19 @@ +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + - id: mixed-line-ending + args: ['--fix', 'lf'] + - id: fix-byte-order-marker + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: debug-statements + - id: check-yaml + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.15.4 + hooks: + - id: ruff-check + args: ['--fix', '--unsafe-fixes'] + - id: ruff-format diff --git a/scripts/update-rtfd b/scripts/update-rtfd index 705e5036..048a9dee 100755 --- a/scripts/update-rtfd +++ b/scripts/update-rtfd @@ -2,9 +2,8 @@ from urllib2 import urlopen +WEB_HOOK = "http://readthedocs.org/build/588" -WEB_HOOK = 'http://readthedocs.org/build/588' - -if __name__ == '__main__': - urlopen(WEB_HOOK, data=' ') +if __name__ == "__main__": + urlopen(WEB_HOOK, data=" ") diff --git a/testtools/run.py b/testtools/run.py old mode 100755 new mode 100644 diff --git a/tox.ini b/tox.ini index 6cf33bac..e8868b29 100644 --- a/tox.ini +++ b/tox.ini @@ -12,10 +12,9 @@ commands = [testenv:ruff] deps = - ruff + pre-commit commands = - ruff check --fix . - ruff format . + pre-commit run -a [testenv:mypy] deps =