Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
3b0047d8
Kaydet (Commit)
3b0047d8
authored
Eki 23, 2018
tarafından
Alexey Izbyshev
Kaydeden (comit)
Tal Einat
Eki 23, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-34482: test datetime classes' handling of non-UTF-8-encodable strings (GH-8878)
üst
83a07652
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
datetimetester.py
Lib/test/datetimetester.py
+40
-0
No files found.
Lib/test/datetimetester.py
Dosyayı görüntüle @
3b0047d8
...
...
@@ -303,6 +303,8 @@ class TestTimeZone(unittest.TestCase):
self
.
assertEqual
(
'UTC+09:30'
,
timezone
(
9.5
*
HOUR
)
.
tzname
(
None
))
self
.
assertEqual
(
'UTC-00:01'
,
timezone
(
timedelta
(
minutes
=-
1
))
.
tzname
(
None
))
self
.
assertEqual
(
'XYZ'
,
timezone
(
-
5
*
HOUR
,
'XYZ'
)
.
tzname
(
None
))
# bpo-34482: Check that surrogates are handled properly.
self
.
assertEqual
(
'
\ud800
'
,
timezone
(
ZERO
,
'
\ud800
'
)
.
tzname
(
None
))
# Sub-minute offsets:
self
.
assertEqual
(
'UTC+01:06:40'
,
timezone
(
timedelta
(
0
,
4000
))
.
tzname
(
None
))
...
...
@@ -1308,6 +1310,12 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase):
except
ValueError
:
pass
# bpo-34482: Check that surrogates don't cause a crash.
try
:
t
.
strftime
(
'
%
y
\ud800
%
m'
)
except
UnicodeEncodeError
:
pass
#check that this standard extension works
t
.
strftime
(
"
%
f"
)
...
...
@@ -1747,6 +1755,9 @@ class TestDateTime(TestDate):
self
.
assertEqual
(
t
.
isoformat
(
'T'
),
"0001-02-03T04:05:01.000123"
)
self
.
assertEqual
(
t
.
isoformat
(
' '
),
"0001-02-03 04:05:01.000123"
)
self
.
assertEqual
(
t
.
isoformat
(
'
\x00
'
),
"0001-02-03
\x00
04:05:01.000123"
)
# bpo-34482: Check that surrogates are handled properly.
self
.
assertEqual
(
t
.
isoformat
(
'
\ud800
'
),
"0001-02-03
\ud800
04:05:01.000123"
)
self
.
assertEqual
(
t
.
isoformat
(
timespec
=
'hours'
),
"0001-02-03T04"
)
self
.
assertEqual
(
t
.
isoformat
(
timespec
=
'minutes'
),
"0001-02-03T04:05"
)
self
.
assertEqual
(
t
.
isoformat
(
timespec
=
'seconds'
),
"0001-02-03T04:05:01"
)
...
...
@@ -1755,6 +1766,8 @@ class TestDateTime(TestDate):
self
.
assertEqual
(
t
.
isoformat
(
timespec
=
'auto'
),
"0001-02-03T04:05:01.000123"
)
self
.
assertEqual
(
t
.
isoformat
(
sep
=
' '
,
timespec
=
'minutes'
),
"0001-02-03 04:05"
)
self
.
assertRaises
(
ValueError
,
t
.
isoformat
,
timespec
=
'foo'
)
# bpo-34482: Check that surrogates are handled properly.
self
.
assertRaises
(
ValueError
,
t
.
isoformat
,
timespec
=
'
\ud800
'
)
# str is ISO format with the separator forced to a blank.
self
.
assertEqual
(
str
(
t
),
"0001-02-03 04:05:01.000123"
)
...
...
@@ -2286,6 +2299,19 @@ class TestDateTime(TestDate):
self
.
assertIs
(
type
(
expected
),
self
.
theclass
)
self
.
assertIs
(
type
(
got
),
self
.
theclass
)
# bpo-34482: Check that surrogates are handled properly.
inputs
=
[
(
'2004-12-01
\ud800
13:02:47.197'
,
'
%
Y-
%
m-
%
d
\ud800
%
H:
%
M:
%
S.
%
f'
),
(
'2004
\ud800
12-01 13:02:47.197'
,
'
%
Y
\ud800
%
m-
%
d
%
H:
%
M:
%
S.
%
f'
),
(
'2004-12-01 13:02
\ud800
47.197'
,
'
%
Y-
%
m-
%
d
%
H:
%
M
\ud800
%
S.
%
f'
),
]
for
string
,
format
in
inputs
:
with
self
.
subTest
(
string
=
string
,
format
=
format
):
expected
=
_strptime
.
_strptime_datetime
(
self
.
theclass
,
string
,
format
)
got
=
self
.
theclass
.
strptime
(
string
,
format
)
self
.
assertEqual
(
expected
,
got
)
strptime
=
self
.
theclass
.
strptime
self
.
assertEqual
(
strptime
(
"+0002"
,
"
%
z"
)
.
utcoffset
(),
2
*
MINUTE
)
self
.
assertEqual
(
strptime
(
"-0002"
,
"
%
z"
)
.
utcoffset
(),
-
2
*
MINUTE
)
...
...
@@ -2353,6 +2379,12 @@ class TestDateTime(TestDate):
t
=
t
.
replace
(
tzinfo
=
tz
)
self
.
assertEqual
(
t
.
strftime
(
"
%
z"
),
"-0200"
+
z
)
# bpo-34482: Check that surrogates don't cause a crash.
try
:
t
.
strftime
(
'
%
y
\ud800
%
m
%
H
\ud800
%
M'
)
except
UnicodeEncodeError
:
pass
def
test_extract
(
self
):
dt
=
self
.
theclass
(
2002
,
3
,
4
,
18
,
45
,
3
,
1234
)
self
.
assertEqual
(
dt
.
date
(),
date
(
2002
,
3
,
4
))
...
...
@@ -2878,6 +2910,8 @@ class TestTime(HarmlessMixedComparison, unittest.TestCase):
self
.
assertEqual
(
t
.
isoformat
(
timespec
=
'microseconds'
),
"12:34:56.123456"
)
self
.
assertEqual
(
t
.
isoformat
(
timespec
=
'auto'
),
"12:34:56.123456"
)
self
.
assertRaises
(
ValueError
,
t
.
isoformat
,
timespec
=
'monkey'
)
# bpo-34482: Check that surrogates are handled properly.
self
.
assertRaises
(
ValueError
,
t
.
isoformat
,
timespec
=
'
\ud800
'
)
t
=
self
.
theclass
(
hour
=
12
,
minute
=
34
,
second
=
56
,
microsecond
=
999500
)
self
.
assertEqual
(
t
.
isoformat
(
timespec
=
'milliseconds'
),
"12:34:56.999"
)
...
...
@@ -2928,6 +2962,12 @@ class TestTime(HarmlessMixedComparison, unittest.TestCase):
# A naive object replaces %z and %Z with empty strings.
self
.
assertEqual
(
t
.
strftime
(
"'
%
z' '
%
Z'"
),
"'' ''"
)
# bpo-34482: Check that surrogates don't cause a crash.
try
:
t
.
strftime
(
'
%
H
\ud800
%
M'
)
except
UnicodeEncodeError
:
pass
def
test_format
(
self
):
t
=
self
.
theclass
(
1
,
2
,
3
,
4
)
self
.
assertEqual
(
t
.
__format__
(
''
),
str
(
t
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment