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
a049f579
Kaydet (Commit)
a049f579
authored
Şub 22, 2018
tarafından
Paul Ganssle
Kaydeden (comit)
Alexander Belopolsky
Şub 22, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Test that new_timezone can return the UTC singleton (gh-5318)
üst
48e8c82f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
0 deletions
+46
-0
datetimetester.py
Lib/test/datetimetester.py
+22
-0
_testcapimodule.c
Modules/_testcapimodule.c
+24
-0
No files found.
Lib/test/datetimetester.py
Dosyayı görüntüle @
a049f579
...
...
@@ -5489,6 +5489,28 @@ class CapiTest(unittest.TestCase):
self
.
assertEqual
(
dt1
.
astimezone
(
timezone
.
utc
),
dt_utc
)
def
test_timezones_offset_zero
(
self
):
utc0
,
utc1
,
non_utc
=
_testcapi
.
get_timezones_offset_zero
()
with
self
.
subTest
(
testname
=
"utc0"
):
self
.
assertIs
(
utc0
,
timezone
.
utc
)
with
self
.
subTest
(
testname
=
"utc1"
):
self
.
assertIs
(
utc1
,
timezone
.
utc
)
with
self
.
subTest
(
testname
=
"non_utc"
):
self
.
assertIsNot
(
non_utc
,
timezone
.
utc
)
non_utc_exp
=
timezone
(
timedelta
(
hours
=
0
),
""
)
self
.
assertEqual
(
non_utc
,
non_utc_exp
)
dt1
=
datetime
(
2000
,
2
,
4
,
tzinfo
=
non_utc
)
dt2
=
datetime
(
2000
,
2
,
4
,
tzinfo
=
non_utc_exp
)
self
.
assertEqual
(
dt1
,
dt2
)
self
.
assertEqual
(
dt1
.
tzname
(),
dt2
.
tzname
())
def
test_check_date
(
self
):
class
DateSubclass
(
date
):
pass
...
...
Modules/_testcapimodule.c
Dosyayı görüntüle @
a049f579
...
...
@@ -2293,6 +2293,29 @@ make_timezones_capi(PyObject *self, PyObject *args) {
return
rv
;
}
static
PyObject
*
get_timezones_offset_zero
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
offset
=
PyDelta_FromDSU
(
0
,
0
,
0
);
PyObject
*
name
=
PyUnicode_FromString
(
""
);
// These two should return the UTC singleton
PyObject
*
utc_singleton_0
=
PyTimeZone_FromOffset
(
offset
);
PyObject
*
utc_singleton_1
=
PyTimeZone_FromOffsetAndName
(
offset
,
NULL
);
// This one will return +00:00 zone, but not the UTC singleton
PyObject
*
non_utc_zone
=
PyTimeZone_FromOffsetAndName
(
offset
,
name
);
Py_DecRef
(
offset
);
Py_DecRef
(
name
);
PyObject
*
rv
=
PyTuple_New
(
3
);
PyTuple_SET_ITEM
(
rv
,
0
,
utc_singleton_0
);
PyTuple_SET_ITEM
(
rv
,
1
,
utc_singleton_1
);
PyTuple_SET_ITEM
(
rv
,
2
,
non_utc_zone
);
return
rv
;
}
static
PyObject
*
get_timezone_utc_capi
(
PyObject
*
self
,
PyObject
*
args
)
{
int
macro
=
0
;
...
...
@@ -4540,6 +4563,7 @@ static PyMethodDef TestMethods[] = {
{
"datetime_check_delta"
,
datetime_check_delta
,
METH_VARARGS
},
{
"datetime_check_tzinfo"
,
datetime_check_tzinfo
,
METH_VARARGS
},
{
"make_timezones_capi"
,
make_timezones_capi
,
METH_NOARGS
},
{
"get_timezones_offset_zero"
,
get_timezones_offset_zero
,
METH_NOARGS
},
{
"get_timezone_utc_capi"
,
get_timezone_utc_capi
,
METH_VARARGS
},
{
"test_list_api"
,
(
PyCFunction
)
test_list_api
,
METH_NOARGS
},
{
"test_dict_iteration"
,
(
PyCFunction
)
test_dict_iteration
,
METH_NOARGS
},
...
...
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