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
3cc8f211
Kaydet (Commit)
3cc8f211
authored
Mar 15, 2010
tarafından
Florent Xicluna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #7783 and #7787: open_urlresource invalidates the outdated files from the local cache.
Use this feature to fix test_normalization.
üst
fae23dc9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
13 deletions
+37
-13
test_normalization.py
Lib/test/test_normalization.py
+7
-9
test_support.py
Lib/test/test_support.py
+24
-4
NEWS
Misc/NEWS
+6
-0
No files found.
Lib/test/test_normalization.py
Dosyayı görüntüle @
3cc8f211
...
...
@@ -6,15 +6,12 @@ import sys
import
os
from
unicodedata
import
normalize
,
unidata_version
TESTDATAFILE
=
"NormalizationTest
"
+
os
.
extsep
+
"
txt"
TESTDATAFILE
=
"NormalizationTest
.
txt"
TESTDATAURL
=
"http://www.unicode.org/Public/"
+
unidata_version
+
"/ucd/"
+
TESTDATAFILE
if
os
.
path
.
exists
(
TESTDATAFILE
):
f
=
open
(
TESTDATAFILE
)
l
=
f
.
readline
()
f
.
close
()
if
not
unidata_version
in
l
:
os
.
unlink
(
TESTDATAFILE
)
def
check_version
(
testfile
):
hdr
=
testfile
.
readline
()
return
unidata_version
in
hdr
class
RangeError
(
Exception
):
pass
...
...
@@ -40,13 +37,14 @@ def unistr(data):
class
NormalizationTest
(
unittest
.
TestCase
):
def
test_main
(
self
):
part
=
None
part1_data
=
{}
# Hit the exception early
try
:
open_urlresource
(
TESTDATAURL
)
testdata
=
open_urlresource
(
TESTDATAURL
,
check_version
)
except
(
IOError
,
HTTPException
):
self
.
skipTest
(
"Could not retrieve "
+
TESTDATAURL
)
for
line
in
open_urlresource
(
TESTDATAURL
)
:
for
line
in
testdata
:
if
'#'
in
line
:
line
=
line
.
split
(
'#'
)[
0
]
line
=
line
.
strip
()
...
...
Lib/test/test_support.py
Dosyayı görüntüle @
3cc8f211
...
...
@@ -32,6 +32,7 @@ __all__ = ["Error", "TestFailed", "ResourceDenied", "import_module",
"threading_cleanup"
,
"reap_children"
,
"cpython_only"
,
"check_impl_detail"
,
"get_attribute"
,
"py3k_bytes"
]
class
Error
(
Exception
):
"""Base class for regression test exceptions."""
...
...
@@ -463,15 +464,30 @@ def check_syntax_error(testcase, statement):
testcase
.
assertRaises
(
SyntaxError
,
compile
,
statement
,
'<test string>'
,
'exec'
)
def
open_urlresource
(
url
):
def
open_urlresource
(
url
,
check
=
None
):
import
urlparse
,
urllib2
requires
(
'urlfetch'
)
filename
=
urlparse
.
urlparse
(
url
)[
2
]
.
split
(
'/'
)[
-
1
]
# '/': it's URL!
fn
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"data"
,
filename
)
def
check_valid_file
(
fn
):
f
=
open
(
fn
)
if
check
is
None
:
return
f
elif
check
(
f
):
f
.
seek
(
0
)
return
f
f
.
close
()
if
os
.
path
.
exists
(
fn
):
return
open
(
fn
)
f
=
check_valid_file
(
fn
)
if
f
is
not
None
:
return
f
unlink
(
fn
)
# Verify the requirement before downloading the file
requires
(
'urlfetch'
)
print
>>
get_original_stdout
(),
'
\t
fetching
%
s ...'
%
url
f
=
urllib2
.
urlopen
(
url
,
timeout
=
15
)
...
...
@@ -483,7 +499,11 @@ def open_urlresource(url):
s
=
f
.
read
()
finally
:
f
.
close
()
return
open
(
fn
)
f
=
check_valid_file
(
fn
)
if
f
is
not
None
:
return
f
raise
TestFailed
(
'invalid resource "
%
s"'
%
fn
)
class
WarningsRecorder
(
object
):
...
...
Misc/NEWS
Dosyayı görüntüle @
3cc8f211
...
...
@@ -76,6 +76,12 @@ Build
- Issue #7705: Fix linking on FreeBSD.
Tests
-----
- Issue #7783: test.test_support.open_urlresource invalidates the outdated
files from the local cache.
What's New in Python 2.7 alpha 4?
=================================
...
...
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