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
39d7063d
Kaydet (Commit)
39d7063d
authored
Şub 18, 2015
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge heads
üst
9dd25dd6
8aba316f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
40 deletions
+61
-40
test__locale.py
Lib/test/test__locale.py
+60
-39
test_locale.py
Lib/test/test_locale.py
+1
-1
No files found.
Lib/test/test__locale.py
Dosyayı görüntüle @
39d7063d
...
@@ -9,7 +9,6 @@ import locale
...
@@ -9,7 +9,6 @@ import locale
import
sys
import
sys
import
unittest
import
unittest
from
platform
import
uname
from
platform
import
uname
from
test.support
import
run_unittest
if
uname
()
.
system
==
"Darwin"
:
if
uname
()
.
system
==
"Darwin"
:
maj
,
min
,
mic
=
[
int
(
part
)
for
part
in
uname
()
.
release
.
split
(
"."
)]
maj
,
min
,
mic
=
[
int
(
part
)
for
part
in
uname
()
.
release
.
split
(
"."
)]
...
@@ -24,45 +23,52 @@ candidate_locales = ['es_UY', 'fr_FR', 'fi_FI', 'es_CO', 'pt_PT', 'it_IT',
...
@@ -24,45 +23,52 @@ candidate_locales = ['es_UY', 'fr_FR', 'fi_FI', 'es_CO', 'pt_PT', 'it_IT',
'da_DK'
,
'nn_NO'
,
'cs_CZ'
,
'de_LU'
,
'es_BO'
,
'sq_AL'
,
'sk_SK'
,
'fr_CH'
,
'da_DK'
,
'nn_NO'
,
'cs_CZ'
,
'de_LU'
,
'es_BO'
,
'sq_AL'
,
'sk_SK'
,
'fr_CH'
,
'de_DE'
,
'sr_YU'
,
'br_FR'
,
'nl_BE'
,
'sv_FI'
,
'pl_PL'
,
'fr_CA'
,
'fo_FO'
,
'de_DE'
,
'sr_YU'
,
'br_FR'
,
'nl_BE'
,
'sv_FI'
,
'pl_PL'
,
'fr_CA'
,
'fo_FO'
,
'bs_BA'
,
'fr_LU'
,
'kl_GL'
,
'fa_IR'
,
'de_BE'
,
'sv_SE'
,
'it_CH'
,
'uk_UA'
,
'bs_BA'
,
'fr_LU'
,
'kl_GL'
,
'fa_IR'
,
'de_BE'
,
'sv_SE'
,
'it_CH'
,
'uk_UA'
,
'eu_ES'
,
'vi_VN'
,
'af_ZA'
,
'nb_NO'
,
'en_DK'
,
'tg_TJ'
,
'en_US'
,
'eu_ES'
,
'vi_VN'
,
'af_ZA'
,
'nb_NO'
,
'en_DK'
,
'tg_TJ'
,
'
ps_AF'
,
'
en_US'
,
'es_ES.ISO8859-1'
,
'fr_FR.ISO8859-15'
,
'ru_RU.KOI8-R'
,
'ko_KR.eucKR'
]
'es_ES.ISO8859-1'
,
'fr_FR.ISO8859-15'
,
'ru_RU.KOI8-R'
,
'ko_KR.eucKR'
]
# Issue #13441: Skip some locales (e.g. cs_CZ and hu_HU) on Solaris to
def
setUpModule
():
# workaround a mbstowcs() bug. For example, on Solaris, the hu_HU locale uses
global
candidate_locales
# the locale encoding ISO-8859-2, the thousauds separator is b'\xA0' and it is
# Issue #13441: Skip some locales (e.g. cs_CZ and hu_HU) on Solaris to
# decoded as U+30000020 (an invalid character) by mbstowcs().
# workaround a mbstowcs() bug. For example, on Solaris, the hu_HU locale uses
if
sys
.
platform
==
'sunos5'
:
# the locale encoding ISO-8859-2, the thousauds separator is b'\xA0' and it is
old_locale
=
locale
.
setlocale
(
locale
.
LC_ALL
)
# decoded as U+30000020 (an invalid character) by mbstowcs().
try
:
if
sys
.
platform
==
'sunos5'
:
locales
=
[]
old_locale
=
locale
.
setlocale
(
locale
.
LC_ALL
)
for
loc
in
candidate_locales
:
try
:
try
:
locales
=
[]
locale
.
setlocale
(
locale
.
LC_ALL
,
loc
)
for
loc
in
candidate_locales
:
except
Error
:
try
:
continue
locale
.
setlocale
(
locale
.
LC_ALL
,
loc
)
encoding
=
locale
.
getpreferredencoding
(
False
)
except
Error
:
try
:
continue
localeconv
()
encoding
=
locale
.
getpreferredencoding
(
False
)
except
Exception
as
err
:
try
:
print
(
"WARNING: Skip locale
%
s (encoding
%
s): [
%
s]
%
s"
localeconv
()
%
(
loc
,
encoding
,
type
(
err
),
err
))
except
Exception
as
err
:
else
:
print
(
"WARNING: Skip locale
%
s (encoding
%
s): [
%
s]
%
s"
locales
.
append
(
loc
)
%
(
loc
,
encoding
,
type
(
err
),
err
))
candidate_locales
=
locales
else
:
finally
:
locales
.
append
(
loc
)
locale
.
setlocale
(
locale
.
LC_ALL
,
old_locale
)
candidate_locales
=
locales
finally
:
# Workaround for MSVC6(debug) crash bug
locale
.
setlocale
(
locale
.
LC_ALL
,
old_locale
)
if
"MSC v.1200"
in
sys
.
version
:
def
accept
(
loc
):
# Workaround for MSVC6(debug) crash bug
a
=
loc
.
split
(
"."
)
if
"MSC v.1200"
in
sys
.
version
:
return
not
(
len
(
a
)
==
2
and
len
(
a
[
-
1
])
>=
9
)
def
accept
(
loc
):
candidate_locales
=
[
loc
for
loc
in
candidate_locales
if
accept
(
loc
)]
a
=
loc
.
split
(
"."
)
return
not
(
len
(
a
)
==
2
and
len
(
a
[
-
1
])
>=
9
)
candidate_locales
=
[
loc
for
loc
in
candidate_locales
if
accept
(
loc
)]
# List known locale values to test against when available.
# List known locale values to test against when available.
# Dict formatted as ``<locale> : (<decimal_point>, <thousands_sep>)``. If a
# Dict formatted as ``<locale> : (<decimal_point>, <thousands_sep>)``. If a
# value is not known, use '' .
# value is not known, use '' .
known_numerics
=
{
'fr_FR'
:
(
','
,
''
),
'en_US'
:(
'.'
,
','
)}
known_numerics
=
{
'en_US'
:
(
'.'
,
','
),
'fr_FR'
:
(
','
,
' '
),
'de_DE'
:
(
','
,
'.'
),
'ps_AF'
:
(
'
\u066b
'
,
'
\u066c
'
),
}
class
_LocaleTests
(
unittest
.
TestCase
):
class
_LocaleTests
(
unittest
.
TestCase
):
...
@@ -91,10 +97,12 @@ class _LocaleTests(unittest.TestCase):
...
@@ -91,10 +97,12 @@ class _LocaleTests(unittest.TestCase):
calc_value
,
known_value
,
calc_value
,
known_value
,
calc_type
,
data_type
,
set_locale
,
calc_type
,
data_type
,
set_locale
,
used_locale
))
used_locale
))
return
True
@unittest.skipUnless
(
nl_langinfo
,
"nl_langinfo is not available"
)
@unittest.skipUnless
(
nl_langinfo
,
"nl_langinfo is not available"
)
def
test_lc_numeric_nl_langinfo
(
self
):
def
test_lc_numeric_nl_langinfo
(
self
):
# Test nl_langinfo against known values
# Test nl_langinfo against known values
tested
=
False
for
loc
in
candidate_locales
:
for
loc
in
candidate_locales
:
try
:
try
:
setlocale
(
LC_NUMERIC
,
loc
)
setlocale
(
LC_NUMERIC
,
loc
)
...
@@ -103,10 +111,14 @@ class _LocaleTests(unittest.TestCase):
...
@@ -103,10 +111,14 @@ class _LocaleTests(unittest.TestCase):
continue
continue
for
li
,
lc
in
((
RADIXCHAR
,
"decimal_point"
),
for
li
,
lc
in
((
RADIXCHAR
,
"decimal_point"
),
(
THOUSEP
,
"thousands_sep"
)):
(
THOUSEP
,
"thousands_sep"
)):
self
.
numeric_tester
(
'nl_langinfo'
,
nl_langinfo
(
li
),
lc
,
loc
)
if
self
.
numeric_tester
(
'nl_langinfo'
,
nl_langinfo
(
li
),
lc
,
loc
):
tested
=
True
if
not
tested
:
self
.
skipTest
(
'no suitable locales'
)
def
test_lc_numeric_localeconv
(
self
):
def
test_lc_numeric_localeconv
(
self
):
# Test localeconv against known values
# Test localeconv against known values
tested
=
False
for
loc
in
candidate_locales
:
for
loc
in
candidate_locales
:
try
:
try
:
setlocale
(
LC_NUMERIC
,
loc
)
setlocale
(
LC_NUMERIC
,
loc
)
...
@@ -116,11 +128,15 @@ class _LocaleTests(unittest.TestCase):
...
@@ -116,11 +128,15 @@ class _LocaleTests(unittest.TestCase):
formatting
=
localeconv
()
formatting
=
localeconv
()
for
lc
in
(
"decimal_point"
,
for
lc
in
(
"decimal_point"
,
"thousands_sep"
):
"thousands_sep"
):
self
.
numeric_tester
(
'localeconv'
,
formatting
[
lc
],
lc
,
loc
)
if
self
.
numeric_tester
(
'localeconv'
,
formatting
[
lc
],
lc
,
loc
):
tested
=
True
if
not
tested
:
self
.
skipTest
(
'no suitable locales'
)
@unittest.skipUnless
(
nl_langinfo
,
"nl_langinfo is not available"
)
@unittest.skipUnless
(
nl_langinfo
,
"nl_langinfo is not available"
)
def
test_lc_numeric_basic
(
self
):
def
test_lc_numeric_basic
(
self
):
# Test nl_langinfo against localeconv
# Test nl_langinfo against localeconv
tested
=
False
for
loc
in
candidate_locales
:
for
loc
in
candidate_locales
:
try
:
try
:
setlocale
(
LC_NUMERIC
,
loc
)
setlocale
(
LC_NUMERIC
,
loc
)
...
@@ -140,10 +156,14 @@ class _LocaleTests(unittest.TestCase):
...
@@ -140,10 +156,14 @@ class _LocaleTests(unittest.TestCase):
"(set to
%
s, using
%
s)"
%
(
"(set to
%
s, using
%
s)"
%
(
nl_radixchar
,
li_radixchar
,
nl_radixchar
,
li_radixchar
,
loc
,
set_locale
))
loc
,
set_locale
))
tested
=
True
if
not
tested
:
self
.
skipTest
(
'no suitable locales'
)
def
test_float_parsing
(
self
):
def
test_float_parsing
(
self
):
# Bug #1391872: Test whether float parsing is okay on European
# Bug #1391872: Test whether float parsing is okay on European
# locales.
# locales.
tested
=
False
for
loc
in
candidate_locales
:
for
loc
in
candidate_locales
:
try
:
try
:
setlocale
(
LC_NUMERIC
,
loc
)
setlocale
(
LC_NUMERIC
,
loc
)
...
@@ -162,9 +182,10 @@ class _LocaleTests(unittest.TestCase):
...
@@ -162,9 +182,10 @@ class _LocaleTests(unittest.TestCase):
if
localeconv
()[
'decimal_point'
]
!=
'.'
:
if
localeconv
()[
'decimal_point'
]
!=
'.'
:
self
.
assertRaises
(
ValueError
,
float
,
self
.
assertRaises
(
ValueError
,
float
,
localeconv
()[
'decimal_point'
]
.
join
([
'1'
,
'23'
]))
localeconv
()[
'decimal_point'
]
.
join
([
'1'
,
'23'
]))
tested
=
True
if
not
tested
:
self
.
skipTest
(
'no suitable locales'
)
def
test_main
():
run_unittest
(
_LocaleTests
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_
main
()
unittest
.
main
()
Lib/test/test_locale.py
Dosyayı görüntüle @
39d7063d
...
@@ -511,7 +511,7 @@ class TestMiscellaneous(unittest.TestCase):
...
@@ -511,7 +511,7 @@ class TestMiscellaneous(unittest.TestCase):
self
.
skipTest
(
'test needs Turkish locale'
)
self
.
skipTest
(
'test needs Turkish locale'
)
loc
=
locale
.
getlocale
(
locale
.
LC_CTYPE
)
loc
=
locale
.
getlocale
(
locale
.
LC_CTYPE
)
if
verbose
:
if
verbose
:
print
(
'
got locale
%
a'
%
(
loc
,)
)
print
(
'
testing with
%
a'
%
(
loc
,),
end
=
' '
,
flush
=
True
)
locale
.
setlocale
(
locale
.
LC_CTYPE
,
loc
)
locale
.
setlocale
(
locale
.
LC_CTYPE
,
loc
)
self
.
assertEqual
(
loc
,
locale
.
getlocale
(
locale
.
LC_CTYPE
))
self
.
assertEqual
(
loc
,
locale
.
getlocale
(
locale
.
LC_CTYPE
))
...
...
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