You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
180 lines
6.6 KiB
180 lines
6.6 KiB
From 3038382d8b01912358419cee96a56730499881e1 Mon Sep 17 00:00:00 2001
|
|
From: Adi Roiban <adi.roiban@chevah.com>
|
|
Date: Mon, 18 Dec 2023 13:42:28 +0000
|
|
Subject: [PATCH 1/4] Run with latest Python.
|
|
|
|
---
|
|
.github/workflows/test.yaml | 6 +++---
|
|
src/twisted/newsfragments/12052.1.misc | 0
|
|
2 files changed, 3 insertions(+), 3 deletions(-)
|
|
create mode 100644 src/twisted/newsfragments/12052.1.misc
|
|
|
|
diff --git a/src/twisted/newsfragments/12052.1.misc b/src/twisted/newsfragments/12052.1.misc
|
|
new file mode 100644
|
|
index 00000000000..e69de29bb2d
|
|
|
|
From e208717cb5f9831a81d4e867c42cf66016bd70f6 Mon Sep 17 00:00:00 2001
|
|
From: Adi Roiban <adi.roiban@chevah.com>
|
|
Date: Mon, 18 Dec 2023 13:43:02 +0000
|
|
Subject: [PATCH 2/4] Add support for latest python 3.12.1 unittest skip
|
|
method.
|
|
|
|
---
|
|
src/twisted/trial/reporter.py | 10 +++++++++-
|
|
1 file changed, 9 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/twisted/trial/reporter.py b/src/twisted/trial/reporter.py
|
|
index 2664b2fe0d5..2f6b8909a0e 100644
|
|
--- a/src/twisted/trial/reporter.py
|
|
+++ b/src/twisted/trial/reporter.py
|
|
@@ -96,6 +96,11 @@ class TestResult(pyunit.TestResult):
|
|
expectedFailures: List[Tuple[itrial.ITestCase, str, "Todo"]] # type: ignore[assignment]
|
|
unexpectedSuccesses: List[Tuple[itrial.ITestCase, str]] # type: ignore[assignment]
|
|
successes: int
|
|
+ # The time when the test was started.
|
|
+ # It might be 0 if the tests was skipped, so never started.
|
|
+ _testStarted: int
|
|
+ # The duration of the test. It can be zero if tests was skipped.
|
|
+ _lastTime: int
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
@@ -104,6 +109,8 @@ def __init__(self):
|
|
self.unexpectedSuccesses = []
|
|
self.successes = 0
|
|
self._timings = []
|
|
+ self._testStarted = 0
|
|
+ self._lastTime = 0
|
|
|
|
def __repr__(self) -> str:
|
|
return "<%s run=%d errors=%d failures=%d todos=%d dones=%d skips=%d>" % (
|
|
@@ -146,7 +153,8 @@ def stopTest(self, test):
|
|
@type test: L{pyunit.TestCase}
|
|
"""
|
|
super().stopTest(test)
|
|
- self._lastTime = self._getTime() - self._testStarted
|
|
+ if self._testStarted:
|
|
+ self._lastTime = self._getTime() - self._testStarted
|
|
|
|
def addFailure(self, test, fail):
|
|
"""
|
|
|
|
From c14f5f8717a314b1cf70277f1ff766b1962865ec Mon Sep 17 00:00:00 2001
|
|
From: Adi Roiban <adi.roiban@chevah.com>
|
|
Date: Tue, 19 Dec 2023 08:54:50 +0000
|
|
Subject: [PATCH 3/4] Update after review.
|
|
|
|
---
|
|
src/twisted/newsfragments/12052.1.misc | 0
|
|
src/twisted/newsfragments/12052.removal | 4 ++++
|
|
src/twisted/trial/reporter.py | 21 ++++++++++++---------
|
|
3 files changed, 16 insertions(+), 9 deletions(-)
|
|
delete mode 100644 src/twisted/newsfragments/12052.1.misc
|
|
create mode 100644 src/twisted/newsfragments/12052.removal
|
|
|
|
diff --git a/src/twisted/newsfragments/12052.1.misc b/src/twisted/newsfragments/12052.1.misc
|
|
deleted file mode 100644
|
|
index e69de29bb2d..00000000000
|
|
diff --git a/src/twisted/newsfragments/12052.removal b/src/twisted/newsfragments/12052.removal
|
|
new file mode 100644
|
|
index 00000000000..e236451bf57
|
|
--- /dev/null
|
|
+++ b/src/twisted/newsfragments/12052.removal
|
|
@@ -0,0 +1,4 @@
|
|
+twisted.trial.reporter.TestRun.startTest() is no longer called for tests
|
|
+with skip annotation or skip attribute for Python 3.12.1 or newer.
|
|
+This is the result of upstream Python gh-106584 change.
|
|
+The behavior is not change in 3.12.0 or older.
|
|
diff --git a/src/twisted/trial/reporter.py b/src/twisted/trial/reporter.py
|
|
index 2f6b8909a0e..a0e0b8dc506 100644
|
|
--- a/src/twisted/trial/reporter.py
|
|
+++ b/src/twisted/trial/reporter.py
|
|
@@ -7,7 +7,7 @@
|
|
"""
|
|
Defines classes that handle the results of tests.
|
|
"""
|
|
-
|
|
+from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
@@ -16,7 +16,7 @@
|
|
import warnings
|
|
from collections import OrderedDict
|
|
from types import TracebackType
|
|
-from typing import TYPE_CHECKING, List, Tuple, Type, Union
|
|
+from typing import TYPE_CHECKING, List, Optional, Tuple, Type, Union
|
|
|
|
from zope.interface import implementer
|
|
|
|
@@ -87,6 +87,11 @@ class TestResult(pyunit.TestResult):
|
|
|
|
@ivar successes: count the number of successes achieved by the test run.
|
|
@type successes: C{int}
|
|
+
|
|
+ @ivar _startTime: The time when the current test was started. It defaults to
|
|
+ L{None}, which means that the test was skipped.
|
|
+ @ivar _lastTime: The duration of the current test run. It defaults to
|
|
+ L{None}, which means that the test was skipped.
|
|
"""
|
|
|
|
# Used when no todo provided to addExpectedFailure or addUnexpectedSuccess.
|
|
@@ -96,11 +101,9 @@ class TestResult(pyunit.TestResult):
|
|
expectedFailures: List[Tuple[itrial.ITestCase, str, "Todo"]] # type: ignore[assignment]
|
|
unexpectedSuccesses: List[Tuple[itrial.ITestCase, str]] # type: ignore[assignment]
|
|
successes: int
|
|
- # The time when the test was started.
|
|
- # It might be 0 if the tests was skipped, so never started.
|
|
- _testStarted: int
|
|
+ _testStarted: Optional[int]
|
|
# The duration of the test. It can be zero if tests was skipped.
|
|
- _lastTime: int
|
|
+ _lastTime: Optional[int]
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
@@ -109,8 +112,8 @@ def __init__(self):
|
|
self.unexpectedSuccesses = []
|
|
self.successes = 0
|
|
self._timings = []
|
|
- self._testStarted = 0
|
|
- self._lastTime = 0
|
|
+ self._testStarted = None
|
|
+ self._lastTime = None
|
|
|
|
def __repr__(self) -> str:
|
|
return "<%s run=%d errors=%d failures=%d todos=%d dones=%d skips=%d>" % (
|
|
@@ -153,7 +156,7 @@ def stopTest(self, test):
|
|
@type test: L{pyunit.TestCase}
|
|
"""
|
|
super().stopTest(test)
|
|
- if self._testStarted:
|
|
+ if self._testStarted is not None:
|
|
self._lastTime = self._getTime() - self._testStarted
|
|
|
|
def addFailure(self, test, fail):
|
|
|
|
From 10e759a3c365cb4d07f5c8aacf608f63ffc92447 Mon Sep 17 00:00:00 2001
|
|
From: Glyph <glyph@twistedmatrix.com>
|
|
Date: Tue, 19 Dec 2023 13:13:22 -0500
|
|
Subject: [PATCH 4/4] Update src/twisted/trial/reporter.py
|
|
|
|
Co-authored-by: Jean-Paul Calderone <exarkun@twistedmatrix.com>
|
|
---
|
|
src/twisted/trial/reporter.py | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/src/twisted/trial/reporter.py b/src/twisted/trial/reporter.py
|
|
index a0e0b8dc506..a803c5103e0 100644
|
|
--- a/src/twisted/trial/reporter.py
|
|
+++ b/src/twisted/trial/reporter.py
|
|
@@ -102,7 +102,7 @@ class TestResult(pyunit.TestResult):
|
|
unexpectedSuccesses: List[Tuple[itrial.ITestCase, str]] # type: ignore[assignment]
|
|
successes: int
|
|
_testStarted: Optional[int]
|
|
- # The duration of the test. It can be zero if tests was skipped.
|
|
+ # The duration of the test. It is None until the test completes.
|
|
_lastTime: Optional[int]
|
|
|
|
def __init__(self):
|