summaryrefslogtreecommitdiffstats
path: root/Lib/test/datetimetester.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/datetimetester.py')
-rw-r--r--Lib/test/datetimetester.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index 9c6e71c..122f6b5 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -13,6 +13,7 @@ import sys
import os
import pickle
import random
+import re
import struct
import unittest
@@ -2676,6 +2677,14 @@ class TestDateTime(TestDate):
with self.assertRaises(ValueError):
self.theclass.fromisoformat(bad_str)
+ def test_fromisoformat_fails_surrogate(self):
+ # Test that when fromisoformat() fails with a surrogate character as
+ # the separator, the error message contains the original string
+ dtstr = "2018-01-03\ud80001:0113"
+
+ with self.assertRaisesRegex(ValueError, re.escape(repr(dtstr))):
+ self.theclass.fromisoformat(dtstr)
+
def test_fromisoformat_utc(self):
dt_str = '2014-04-19T13:21:13+00:00'
dt = self.theclass.fromisoformat(dt_str)