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
880254e2
Kaydet (Commit)
880254e2
authored
Tem 17, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #17767: test_locale now works with unittest test discovery.
Original patch by Zachary Ware.
üst
6a98fe9e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
41 deletions
+22
-41
test_locale.py
Lib/test/test_locale.py
+19
-41
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_locale.py
Dosyayı görüntüle @
880254e2
from
test.support
import
run_unittest
,
verbose
from
test.support
import
verbose
import
unittest
import
unittest
import
locale
import
locale
import
sys
import
sys
import
codecs
import
codecs
enUS_locale
=
None
class
BaseLocalizedTest
(
unittest
.
TestCase
):
#
# Base class for tests using a real locale
#
def
get_enUS_locale
():
@classmethod
global
enUS_locale
def
setUpClass
(
cls
):
if
sys
.
platform
==
'darwin'
:
if
sys
.
platform
==
'darwin'
:
import
os
import
os
tlocs
=
(
"en_US.UTF-8"
,
"en_US.ISO8859-1"
,
"en_US"
)
tlocs
=
(
"en_US.UTF-8"
,
"en_US.ISO8859-1"
,
"en_US"
)
...
@@ -19,7 +22,9 @@ def get_enUS_locale():
...
@@ -19,7 +22,9 @@ def get_enUS_locale():
elif
sys
.
platform
.
startswith
(
"win"
):
elif
sys
.
platform
.
startswith
(
"win"
):
tlocs
=
(
"En"
,
"English"
)
tlocs
=
(
"En"
,
"English"
)
else
:
else
:
tlocs
=
(
"en_US.UTF-8"
,
"en_US.ISO8859-1"
,
"en_US.US-ASCII"
,
"en_US"
)
tlocs
=
(
"en_US.UTF-8"
,
"en_US.ISO8859-1"
,
"en_US.US-ASCII"
,
"en_US"
)
try
:
oldlocale
=
locale
.
setlocale
(
locale
.
LC_NUMERIC
)
oldlocale
=
locale
.
setlocale
(
locale
.
LC_NUMERIC
)
for
tloc
in
tlocs
:
for
tloc
in
tlocs
:
try
:
try
:
...
@@ -28,25 +33,18 @@ def get_enUS_locale():
...
@@ -28,25 +33,18 @@ def get_enUS_locale():
continue
continue
break
break
else
:
else
:
raise
unittest
.
SkipTest
(
raise
unittest
.
SkipTest
(
"Test locale not supported "
"Test locale not supported (tried
%
s)"
%
(
', '
.
join
(
tlocs
)))
"(tried
%
s)"
%
(
', '
.
join
(
tlocs
)))
enUS_locale
=
tloc
cls
.
enUS_locale
=
tloc
finally
:
locale
.
setlocale
(
locale
.
LC_NUMERIC
,
oldlocale
)
locale
.
setlocale
(
locale
.
LC_NUMERIC
,
oldlocale
)
class
BaseLocalizedTest
(
unittest
.
TestCase
):
#
# Base class for tests using a real locale
#
def
setUp
(
self
):
def
setUp
(
self
):
self
.
oldlocale
=
locale
.
setlocale
(
self
.
locale_type
)
oldlocale
=
locale
.
setlocale
(
self
.
locale_type
)
locale
.
setlocale
(
self
.
locale_type
,
enUS_locale
)
self
.
addCleanup
(
locale
.
setlocale
,
self
.
locale_type
,
oldlocale
)
locale
.
setlocale
(
self
.
locale_type
,
self
.
enUS_locale
)
if
verbose
:
if
verbose
:
print
(
"testing with
\"
%
s
\"
..."
%
enUS_locale
,
end
=
' '
)
print
(
"testing with
%
r..."
%
self
.
enUS_locale
,
end
=
' '
,
flush
=
True
)
def
tearDown
(
self
):
locale
.
setlocale
(
self
.
locale_type
,
self
.
oldlocale
)
class
BaseCookedTest
(
unittest
.
TestCase
):
class
BaseCookedTest
(
unittest
.
TestCase
):
...
@@ -415,25 +413,5 @@ class TestMiscellaneous(unittest.TestCase):
...
@@ -415,25 +413,5 @@ class TestMiscellaneous(unittest.TestCase):
locale
.
setlocale
(
locale
.
LC_ALL
,
(
b
'not'
,
b
'valid'
))
locale
.
setlocale
(
locale
.
LC_ALL
,
(
b
'not'
,
b
'valid'
))
def
test_main
():
tests
=
[
TestMiscellaneous
,
TestFormatPatternArg
,
TestLocaleFormatString
,
TestEnUSNumberFormatting
,
TestCNumberFormatting
,
TestFrFRNumberFormatting
,
TestCollation
]
# SkipTest can't be raised inside unittests, handle it manually instead
try
:
get_enUS_locale
()
except
unittest
.
SkipTest
as
e
:
if
verbose
:
print
(
"Some tests will be disabled:
%
s"
%
e
)
else
:
tests
+=
[
TestNumberFormatting
,
TestEnUSCollation
]
run_unittest
(
*
tests
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_
main
()
unittest
.
main
()
Misc/NEWS
Dosyayı görüntüle @
880254e2
...
@@ -198,6 +198,9 @@ IDLE
...
@@ -198,6 +198,9 @@ IDLE
Tests
Tests
-----
-----
- Issue #17767: test_locale now works with unittest test discovery.
Original patch by Zachary Ware.
- Issue #18375: Assume --randomize when --randseed is used for running the
- Issue #18375: Assume --randomize when --randseed is used for running the
testsuite.
testsuite.
...
...
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