156 lines
5.9 KiB
Diff
156 lines
5.9 KiB
Diff
From da3bf3dc29f067e7019b2a1c205834ab64b2139a Mon Sep 17 00:00:00 2001
|
|
From: Paul Eggert <eggert@cs.ucla.edu>
|
|
Date: Fri, 9 Dec 2022 10:16:42 -0800
|
|
Subject: [PATCH 1/3] #11786 fix misuse of mktime in tests
|
|
|
|
---
|
|
src/twisted/logger/test/test_format.py | 27 +++++++++++++-------------
|
|
1 file changed, 14 insertions(+), 13 deletions(-)
|
|
|
|
diff --git a/src/twisted/logger/test/test_format.py b/src/twisted/logger/test/test_format.py
|
|
index dbfbe1af1ae..0671b6662c8 100644
|
|
--- a/src/twisted/logger/test/test_format.py
|
|
+++ b/src/twisted/logger/test/test_format.py
|
|
@@ -166,16 +166,17 @@ def test_formatTimeWithDefaultFormat(self) -> None:
|
|
def testForTimeZone(name: str, expectedDST: str, expectedSTD: str) -> None:
|
|
setTZ(name)
|
|
|
|
- localDST = mktime((2006, 6, 30, 0, 0, 0, 4, 181, 1))
|
|
localSTD = mktime((2007, 1, 31, 0, 0, 0, 2, 31, 0))
|
|
-
|
|
- self.assertEqual(formatTime(localDST), expectedDST)
|
|
self.assertEqual(formatTime(localSTD), expectedSTD)
|
|
|
|
+ if expectedDST:
|
|
+ localDST = mktime((2006, 6, 30, 0, 0, 0, 4, 181, 1))
|
|
+ self.assertEqual(formatTime(localDST), expectedDST)
|
|
+
|
|
# UTC
|
|
testForTimeZone(
|
|
"UTC+00",
|
|
- "2006-06-30T00:00:00+0000",
|
|
+ None,
|
|
"2007-01-31T00:00:00+0000",
|
|
)
|
|
|
|
@@ -196,7 +197,7 @@ def testForTimeZone(name: str, expectedDST: str, expectedSTD: str) -> None:
|
|
# No DST
|
|
testForTimeZone(
|
|
"CST+06",
|
|
- "2006-06-30T00:00:00-0600",
|
|
+ None,
|
|
"2007-01-31T00:00:00-0600",
|
|
)
|
|
|
|
@@ -211,7 +212,7 @@ def test_formatTimeWithNoFormat(self) -> None:
|
|
"""
|
|
If C{timeFormat} argument is L{None}, we get the default output.
|
|
"""
|
|
- t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, 1))
|
|
+ t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, -1))
|
|
self.assertEqual(formatTime(t, timeFormat=None), "-")
|
|
self.assertEqual(formatTime(t, timeFormat=None, default="!"), "!")
|
|
|
|
@@ -219,7 +220,7 @@ def test_formatTimeWithAlternateTimeFormat(self) -> None:
|
|
"""
|
|
Alternate time format in output.
|
|
"""
|
|
- t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, 1))
|
|
+ t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, -1))
|
|
self.assertEqual(formatTime(t, timeFormat="%Y/%W"), "2013/38")
|
|
|
|
def test_formatTimePercentF(self) -> None:
|
|
@@ -246,7 +247,7 @@ def test_formatTimeDefault(self) -> None:
|
|
addTZCleanup(self)
|
|
setTZ("UTC+00")
|
|
|
|
- t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, 1))
|
|
+ t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, -1))
|
|
event = dict(log_format="XYZZY", log_time=t)
|
|
self.assertEqual(
|
|
formatEventAsClassicLogText(event),
|
|
@@ -539,7 +540,7 @@ def test_eventAsTextSystemOnly(self) -> None:
|
|
except CapturedError:
|
|
f = Failure()
|
|
|
|
- t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, 1))
|
|
+ t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, -1))
|
|
event: LogEvent = {
|
|
"log_format": "ABCD",
|
|
"log_system": "fake_system",
|
|
@@ -573,7 +574,7 @@ def test_eventAsTextTimestampOnly(self) -> None:
|
|
except CapturedError:
|
|
f = Failure()
|
|
|
|
- t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, 1))
|
|
+ t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, -1))
|
|
event: LogEvent = {
|
|
"log_format": "ABCD",
|
|
"log_system": "fake_system",
|
|
@@ -601,7 +602,7 @@ def test_eventAsTextSystemMissing(self) -> None:
|
|
except CapturedError:
|
|
f = Failure()
|
|
|
|
- t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, 1))
|
|
+ t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, -1))
|
|
event: LogEvent = {
|
|
"log_format": "ABCD",
|
|
"log_time": t,
|
|
@@ -628,7 +629,7 @@ def test_eventAsTextSystemMissingNamespaceAndLevel(self) -> None:
|
|
except CapturedError:
|
|
f = Failure()
|
|
|
|
- t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, 1))
|
|
+ t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, -1))
|
|
event: LogEvent = {
|
|
"log_format": "ABCD",
|
|
"log_time": t,
|
|
@@ -657,7 +658,7 @@ def test_eventAsTextSystemMissingLevelOnly(self) -> None:
|
|
except CapturedError:
|
|
f = Failure()
|
|
|
|
- t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, 1))
|
|
+ t = mktime((2013, 9, 24, 11, 40, 47, 1, 267, -1))
|
|
event: LogEvent = {
|
|
"log_format": "ABCD",
|
|
"log_time": t,
|
|
|
|
From 29e6f71b536822aa397983a5b84bc5098e10f92d Mon Sep 17 00:00:00 2001
|
|
From: Glyph <code@glyph.im>
|
|
Date: Thu, 31 Aug 2023 15:11:36 -0700
|
|
Subject: [PATCH 2/3] news fragment
|
|
|
|
---
|
|
src/twisted/newsfragments/11787.misc | 0
|
|
1 file changed, 0 insertions(+), 0 deletions(-)
|
|
create mode 100644 src/twisted/newsfragments/11787.misc
|
|
|
|
diff --git a/src/twisted/newsfragments/11787.misc b/src/twisted/newsfragments/11787.misc
|
|
new file mode 100644
|
|
index 00000000000..e69de29bb2d
|
|
|
|
From b696cf9662ddbd7840ded2d9caab0a0bbb7fd386 Mon Sep 17 00:00:00 2001
|
|
From: Glyph <code@glyph.im>
|
|
Date: Thu, 31 Aug 2023 15:17:00 -0700
|
|
Subject: [PATCH 3/3] add Optional annotation
|
|
|
|
---
|
|
src/twisted/logger/test/test_format.py | 4 +++-
|
|
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/twisted/logger/test/test_format.py b/src/twisted/logger/test/test_format.py
|
|
index 0671b6662c8..67dbf0ce784 100644
|
|
--- a/src/twisted/logger/test/test_format.py
|
|
+++ b/src/twisted/logger/test/test_format.py
|
|
@@ -163,7 +163,9 @@ def test_formatTimeWithDefaultFormat(self) -> None:
|
|
if tzset is None:
|
|
raise SkipTest("Platform cannot change timezone; unable to verify offsets.")
|
|
|
|
- def testForTimeZone(name: str, expectedDST: str, expectedSTD: str) -> None:
|
|
+ def testForTimeZone(
|
|
+ name: str, expectedDST: Optional[str], expectedSTD: str
|
|
+ ) -> None:
|
|
setTZ(name)
|
|
|
|
localSTD = mktime((2007, 1, 31, 0, 0, 0, 2, 31, 0))
|