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
ad9a1ba5
Kaydet (Commit)
ad9a1ba5
authored
Şub 18, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #23474: Enhanced locale testing.
üst
a2269d07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
5 deletions
+47
-5
test__locale.py
Lib/test/test__locale.py
+28
-4
test_decimal.py
Lib/test/test_decimal.py
+19
-1
No files found.
Lib/test/test__locale.py
Dosyayı görüntüle @
ad9a1ba5
...
...
@@ -22,7 +22,7 @@ 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'
,
'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'
,
'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.UTF-8'
,
'
en_US'
,
'es_ES.ISO8859-1'
,
'fr_FR.ISO8859-15'
,
'ru_RU.KOI8-R'
,
'ko_KR.eucKR'
]
# Workaround for MSVC6(debug) crash bug
...
...
@@ -35,7 +35,12 @@ if "MSC v.1200" in sys.version:
# List known locale values to test against when available.
# Dict formatted as ``<locale> : (<decimal_point>, <thousands_sep>)``. If a
# value is not known, use '' .
known_numerics
=
{
'fr_FR'
:
(
','
,
''
),
'en_US'
:(
'.'
,
','
)}
known_numerics
=
{
'en_US'
:
(
'.'
,
','
),
'fr_FR'
:
(
','
,
' '
),
'de_DE'
:
(
','
,
'.'
),
'ps_AF.UTF-8'
:
(
'
\xd9\xab
'
,
'
\xd9\xac
'
),
}
class
_LocaleTests
(
unittest
.
TestCase
):
...
...
@@ -64,10 +69,12 @@ class _LocaleTests(unittest.TestCase):
calc_value
,
known_value
,
calc_type
,
data_type
,
set_locale
,
used_locale
))
return
True
@unittest.skipUnless
(
nl_langinfo
,
"nl_langinfo is not available"
)
def
test_lc_numeric_nl_langinfo
(
self
):
# Test nl_langinfo against known values
tested
=
False
for
loc
in
candidate_locales
:
try
:
setlocale
(
LC_NUMERIC
,
loc
)
...
...
@@ -75,21 +82,30 @@ class _LocaleTests(unittest.TestCase):
continue
for
li
,
lc
in
((
RADIXCHAR
,
"decimal_point"
),
(
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
):
# Test localeconv against known values
tested
=
False
for
loc
in
candidate_locales
:
try
:
setlocale
(
LC_NUMERIC
,
loc
)
except
Error
:
continue
formatting
=
localeconv
()
for
lc
in
(
"decimal_point"
,
"thousands_sep"
):
self
.
numeric_tester
(
'localeconv'
,
localeconv
()[
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"
)
def
test_lc_numeric_basic
(
self
):
# Test nl_langinfo against localeconv
tested
=
False
for
loc
in
candidate_locales
:
try
:
setlocale
(
LC_NUMERIC
,
loc
)
...
...
@@ -108,10 +124,14 @@ class _LocaleTests(unittest.TestCase):
"(set to
%
s, using
%
s)"
%
(
nl_radixchar
,
li_radixchar
,
loc
,
set_locale
))
tested
=
True
if
not
tested
:
self
.
skipTest
(
'no suitable locales'
)
def
test_float_parsing
(
self
):
# Bug #1391872: Test whether float parsing is okay on European
# locales.
tested
=
False
for
loc
in
candidate_locales
:
try
:
setlocale
(
LC_NUMERIC
,
loc
)
...
...
@@ -129,6 +149,10 @@ class _LocaleTests(unittest.TestCase):
if
localeconv
()[
'decimal_point'
]
!=
'.'
:
self
.
assertRaises
(
ValueError
,
float
,
localeconv
()[
'decimal_point'
]
.
join
([
'1'
,
'23'
]))
tested
=
True
if
not
tested
:
self
.
skipTest
(
'no suitable locales'
)
def
test_main
():
run_unittest
(
_LocaleTests
)
...
...
Lib/test/test_decimal.py
Dosyayı görüntüle @
ad9a1ba5
...
...
@@ -32,7 +32,8 @@ import unittest
from
decimal
import
*
import
numbers
from
test.test_support
import
(
run_unittest
,
run_doctest
,
requires_unicode
,
u
,
is_resource_enabled
,
check_py3k_warnings
)
is_resource_enabled
,
check_py3k_warnings
,
run_with_locale
)
import
random
try
:
import
threading
...
...
@@ -905,6 +906,23 @@ class DecimalFormatTest(unittest.TestCase):
self
.
assertEqual
(
get_fmt
(
123456
,
crazy
,
'012n'
),
'00-01-2345-6'
)
self
.
assertEqual
(
get_fmt
(
123456
,
crazy
,
'013n'
),
'000-01-2345-6'
)
@run_with_locale
(
'LC_ALL'
,
'ps_AF.UTF-8'
)
def
test_wide_char_separator_decimal_point
(
self
):
# locale with wide char separator and decimal point
import
locale
decimal_point
=
locale
.
localeconv
()[
'decimal_point'
]
thousands_sep
=
locale
.
localeconv
()[
'thousands_sep'
]
if
decimal_point
!=
'
\xd9\xab
'
:
self
.
skipTest
(
'inappropriate decimal point separator'
'({!r} not {!r})'
.
format
(
decimal_point
,
'
\xd9\xab
'
))
if
thousands_sep
!=
'
\xd9\xac
'
:
self
.
skipTest
(
'inappropriate thousands separator'
'({!r} not {!r})'
.
format
(
thousands_sep
,
'
\xd9\xac
'
))
self
.
assertEqual
(
format
(
Decimal
(
'100000000.123'
),
'n'
),
'100
\xd9\xac
000
\xd9\xac
000
\xd9\xab
123'
)
class
DecimalArithmeticOperatorsTest
(
unittest
.
TestCase
):
'''Unit tests for all arithmetic operators, binary and unary.'''
...
...
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