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
524f4135
Kaydet (Commit)
524f4135
authored
Tem 26, 2008
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
try to fix most buildbot failures on test_locale + add a debug output for the solaris buildbot
üst
92f8216b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
19 deletions
+41
-19
test_locale.py
Lib/test/test_locale.py
+41
-19
No files found.
Lib/test/test_locale.py
Dosyayı görüntüle @
524f4135
from
test.test_support
import
run_unittest
,
TestSkipped
,
verbose
from
test.test_support
import
run_unittest
,
verbose
,
TestSkipped
import
unittest
import
locale
import
sys
import
codecs
class
BaseLocalizedTest
(
unittest
.
TestCase
):
#
# Base class for tests using a real locale
#
enUS_locale
=
None
def
get_enUS_locale
():
global
enUS_locale
if
sys
.
platform
==
'darwin'
:
raise
TestSkipped
(
"Locale support on MacOSX is minimal"
)
if
sys
.
platform
.
startswith
(
"win"
):
tlocs
=
(
"En"
,
"English"
)
else
:
tlocs
=
(
"en_US.UTF-8"
,
"en_US.US-ASCII"
,
"en_US"
)
def
setUp
(
self
):
if
sys
.
platform
==
'darwin'
:
raise
TestSkipped
(
"Locale support on MacOSX is minimal and cannot be tested"
)
self
.
oldlocale
=
locale
.
setlocale
(
self
.
locale_type
)
for
tloc
in
self
.
tlocs
:
oldlocale
=
locale
.
setlocale
(
locale
.
LC_NUMERIC
)
for
tloc
in
tlocs
:
try
:
locale
.
setlocale
(
self
.
locale_type
,
tloc
)
locale
.
setlocale
(
locale
.
LC_NUMERIC
,
tloc
)
except
locale
.
Error
:
continue
break
else
:
raise
TestSkipped
(
"Test locale not supported (tried
%
s)"
%
(
', '
.
join
(
self
.
tlocs
)))
"Test locale not supported (tried
%
s)"
%
(
', '
.
join
(
tlocs
)))
enUS_locale
=
tloc
locale
.
setlocale
(
locale
.
LC_NUMERIC
,
oldlocale
)
class
BaseLocalizedTest
(
unittest
.
TestCase
):
#
# Base class for tests using a real locale
#
def
setUp
(
self
):
self
.
oldlocale
=
locale
.
setlocale
(
self
.
locale_type
)
locale
.
setlocale
(
self
.
locale_type
,
enUS_locale
)
if
verbose
:
print
"testing with
\"
%
s
\"
..."
%
tloc
,
print
"testing with
\"
%
s
\"
..."
%
enUS_locale
,
def
tearDown
(
self
):
locale
.
setlocale
(
self
.
locale_type
,
self
.
oldlocale
)
...
...
@@ -132,10 +140,17 @@ class EnUSNumberFormatting(BaseFormattingTest):
def
test_grouping_and_padding
(
self
):
self
.
_test_format
(
"
%20
.f"
,
-
42
,
grouping
=
1
,
out
=
'-42'
.
rjust
(
20
))
try
:
self
.
_test_format
(
"
%+10
.f"
,
-
4200
,
grouping
=
1
,
out
=
(
'-4
%
s200'
%
self
.
sep
)
.
rjust
(
10
))
self
.
_test_format
(
"
%-10
.f"
,
-
4200
,
grouping
=
1
,
out
=
(
'-4
%
s200'
%
self
.
sep
)
.
ljust
(
10
))
except
AssertionError
:
# Temp debug for the Solaris buildbot
import
pprint
print
pprint
.
pprint
(
locale
.
localeconv
())
raise
def
test_integer_grouping
(
self
):
self
.
_test_format
(
"
%
d"
,
4200
,
grouping
=
True
,
out
=
'4
%
s200'
%
self
.
sep
)
...
...
@@ -209,15 +224,14 @@ class TestCNumberFormatting(CCookedTest, BaseFormattingTest):
self
.
_test_format
(
"
%9.2
f"
,
12345.67
,
grouping
=
True
,
out
=
' 12345.67'
)
class
TestStringMethods
(
BaseLocalizedTest
):
if
sys
.
platform
!=
'sunos5'
:
class
TestStringMethods
(
BaseLocalizedTest
):
locale_type
=
locale
.
LC_CTYPE
# Test BSD Rune locale's bug for isctype functions.
def
test_isspace
(
self
):
self
.
assertEqual
(
'
\x20
'
.
isspace
(),
True
)
if
sys
.
platform
==
'sunos5'
:
# On Solaris, in en_US.UTF-8, \xa0 is a space
self
.
assertEqual
(
'
\xa0
'
.
isspace
(),
False
)
self
.
assertEqual
(
'
\xa1
'
.
isspace
(),
False
)
...
...
@@ -261,7 +275,15 @@ class TestMiscellaneous(unittest.TestCase):
def
test_main
():
run_unittest
(
__name__
)
tests
=
[
TestMiscellaneous
,
TestEnUSNumberFormatting
,
TestCNumberFormatting
]
# TestSkipped can't be raised inside unittests, handle it manually instead
try
:
get_enUS_locale
()
except
TestSkipped
as
e
:
print
"Some tests will be disabled:
%
s"
%
e
else
:
tests
+=
[
TestNumberFormatting
,
TestStringMethods
]
run_unittest
(
*
tests
)
if
__name__
==
'__main__'
:
test_main
()
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