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
282d331e
Kaydet (Commit)
282d331e
authored
Kas 26, 2012
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#16559: Add more tests for the json module. Patch by Serhiy Storchaka.
üst
55b4cfb9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
15 deletions
+47
-15
test_fail.py
Lib/json/tests/test_fail.py
+21
-3
test_float.py
Lib/json/tests/test_float.py
+15
-0
test_pass1.py
Lib/json/tests/test_pass1.py
+8
-12
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/json/tests/test_fail.py
Dosyayı görüntüle @
282d331e
from
json.tests
import
PyTest
,
CTest
from
json.tests
import
PyTest
,
CTest
#
Fri Dec 30 18:57:26 20
05
#
2007-10-
05
JSONDOCS
=
[
JSONDOCS
=
[
# http://json.org/JSON_checker/test/fail1.json
# http://json.org/JSON_checker/test/fail1.json
'"A JSON payload should be an object or array, not a string."'
,
'"A JSON payload should be an object or array, not a string."'
,
# http://json.org/JSON_checker/test/fail2.json
# http://json.org/JSON_checker/test/fail2.json
'["Unclosed array"'
,
'["Unclosed array"'
,
# http://json.org/JSON_checker/test/fail3.json
# http://json.org/JSON_checker/test/fail3.json
'{unquoted_key: "keys must be quoted}'
,
'{unquoted_key: "keys must be quoted
"
}'
,
# http://json.org/JSON_checker/test/fail4.json
# http://json.org/JSON_checker/test/fail4.json
'["extra comma",]'
,
'["extra comma",]'
,
# http://json.org/JSON_checker/test/fail5.json
# http://json.org/JSON_checker/test/fail5.json
...
@@ -33,7 +33,7 @@ JSONDOCS = [
...
@@ -33,7 +33,7 @@ JSONDOCS = [
# http://json.org/JSON_checker/test/fail15.json
# http://json.org/JSON_checker/test/fail15.json
'["Illegal backslash escape:
\\
x15"]'
,
'["Illegal backslash escape:
\\
x15"]'
,
# http://json.org/JSON_checker/test/fail16.json
# http://json.org/JSON_checker/test/fail16.json
'[
"Illegal backslash escape:
\\\'
"
]'
,
'[
\\
naked
]'
,
# http://json.org/JSON_checker/test/fail17.json
# http://json.org/JSON_checker/test/fail17.json
'["Illegal backslash escape:
\\
017"]'
,
'["Illegal backslash escape:
\\
017"]'
,
# http://json.org/JSON_checker/test/fail18.json
# http://json.org/JSON_checker/test/fail18.json
...
@@ -50,6 +50,24 @@ JSONDOCS = [
...
@@ -50,6 +50,24 @@ JSONDOCS = [
'["Bad value", truth]'
,
'["Bad value", truth]'
,
# http://json.org/JSON_checker/test/fail24.json
# http://json.org/JSON_checker/test/fail24.json
"['single quote']"
,
"['single quote']"
,
# http://json.org/JSON_checker/test/fail25.json
'["
\t
tab
\t
character
\t
in
\t
string
\t
"]'
,
# http://json.org/JSON_checker/test/fail26.json
'["tab
\\
character
\\
in
\\
string
\\
"]'
,
# http://json.org/JSON_checker/test/fail27.json
'["line
\n
break"]'
,
# http://json.org/JSON_checker/test/fail28.json
'["line
\\\n
break"]'
,
# http://json.org/JSON_checker/test/fail29.json
'[0e]'
,
# http://json.org/JSON_checker/test/fail30.json
'[0e+]'
,
# http://json.org/JSON_checker/test/fail31.json
'[0e+-1]'
,
# http://json.org/JSON_checker/test/fail32.json
'{"Comma instead if closing brace": true,'
,
# http://json.org/JSON_checker/test/fail33.json
'["mismatch"}'
,
# http://code.google.com/p/simplejson/issues/detail?id=3
# http://code.google.com/p/simplejson/issues/detail?id=3
u'["A
\u001F
Z control characters in string"]'
,
u'["A
\u001F
Z control characters in string"]'
,
]
]
...
...
Lib/json/tests/test_float.py
Dosyayı görüntüle @
282d331e
...
@@ -17,6 +17,21 @@ class TestFloat(object):
...
@@ -17,6 +17,21 @@ class TestFloat(object):
self
.
assertEqual
(
self
.
loads
(
self
.
dumps
(
num
)),
num
)
self
.
assertEqual
(
self
.
loads
(
self
.
dumps
(
num
)),
num
)
self
.
assertEqual
(
self
.
loads
(
unicode
(
self
.
dumps
(
num
))),
num
)
self
.
assertEqual
(
self
.
loads
(
unicode
(
self
.
dumps
(
num
))),
num
)
def
test_out_of_range
(
self
):
self
.
assertEqual
(
self
.
loads
(
'[23456789012E666]'
),
[
float
(
'inf'
)])
self
.
assertEqual
(
self
.
loads
(
'[-23456789012E666]'
),
[
float
(
'-inf'
)])
def
test_allow_nan
(
self
):
for
val
in
(
float
(
'inf'
),
float
(
'-inf'
),
float
(
'nan'
)):
out
=
self
.
dumps
([
val
])
if
val
==
val
:
# inf
self
.
assertEqual
(
self
.
loads
(
out
),
[
val
])
else
:
# nan
res
=
self
.
loads
(
out
)
self
.
assertEqual
(
len
(
res
),
1
)
self
.
assertNotEqual
(
res
[
0
],
res
[
0
])
self
.
assertRaises
(
ValueError
,
self
.
dumps
,
[
val
],
allow_nan
=
False
)
class
TestPyFloat
(
TestFloat
,
PyTest
):
pass
class
TestPyFloat
(
TestFloat
,
PyTest
):
pass
class
TestCFloat
(
TestFloat
,
CTest
):
pass
class
TestCFloat
(
TestFloat
,
CTest
):
pass
Lib/json/tests/test_pass1.py
Dosyayı görüntüle @
282d331e
...
@@ -17,7 +17,7 @@ JSON = r'''
...
@@ -17,7 +17,7 @@ JSON = r'''
"real": -9876.543210,
"real": -9876.543210,
"e": 0.123456789e-12,
"e": 0.123456789e-12,
"E": 1.234567890E+34,
"E": 1.234567890E+34,
"": 23456789012E66
6
,
"": 23456789012E66,
"zero": 0,
"zero": 0,
"one": 1,
"one": 1,
"space": " ",
"space": " ",
...
@@ -28,6 +28,7 @@ JSON = r'''
...
@@ -28,6 +28,7 @@ JSON = r'''
"alpha": "abcdefghijklmnopqrstuvwyz",
"alpha": "abcdefghijklmnopqrstuvwyz",
"ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
"ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
"digit": "0123456789",
"digit": "0123456789",
"0123456789": "digit",
"special": "`1~!@#$
%
^&*()_+-={':[,]}|;.</>?",
"special": "`1~!@#$
%
^&*()_+-={':[,]}|;.</>?",
"hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
"hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
"true": true,
"true": true,
...
@@ -43,8 +44,7 @@ JSON = r'''
...
@@ -43,8 +44,7 @@ JSON = r'''
,
,
4 , 5 , 6 ,7 ],
4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7],
"compact": [1,2,3,4,5,6,7],
"jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
"jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
"quotes": "" \u0022
%22
0x22 034 "",
"quotes": "" \u0022
%22
0x22 034 "",
"\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$
%
^&*()_+-=[]{}|;:',./<>?"
"\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$
%
^&*()_+-=[]{}|;:',./<>?"
...
@@ -55,9 +55,11 @@ JSON = r'''
...
@@ -55,9 +55,11 @@ JSON = r'''
99.44
99.44
,
,
1066
1066,
1e1,
0.1e1,
1e-1,
1e00,2e+00,2e-00
,"rosebud"]
,"rosebud"]
'''
'''
...
@@ -67,12 +69,6 @@ class TestPass1(object):
...
@@ -67,12 +69,6 @@ class TestPass1(object):
res
=
self
.
loads
(
JSON
)
res
=
self
.
loads
(
JSON
)
out
=
self
.
dumps
(
res
)
out
=
self
.
dumps
(
res
)
self
.
assertEqual
(
res
,
self
.
loads
(
out
))
self
.
assertEqual
(
res
,
self
.
loads
(
out
))
try
:
self
.
dumps
(
res
,
allow_nan
=
False
)
except
ValueError
:
pass
else
:
self
.
fail
(
"23456789012E666 should be out of range"
)
class
TestPyPass1
(
TestPass1
,
PyTest
):
pass
class
TestPyPass1
(
TestPass1
,
PyTest
):
pass
...
...
Misc/NEWS
Dosyayı görüntüle @
282d331e
...
@@ -518,6 +518,9 @@ Extension Modules
...
@@ -518,6 +518,9 @@ Extension Modules
Tests
Tests
-----
-----
-
Issue
#
16559
:
Add
more
tests
for
the
json
module
,
including
some
from
the
official
test
suite
at
json
.
org
.
Patch
by
Serhiy
Storchaka
.
-
Issue
#
16274
:
Fix
test_asyncore
on
Solaris
.
Patch
by
Giampaolo
Rodola
'.
-
Issue
#
16274
:
Fix
test_asyncore
on
Solaris
.
Patch
by
Giampaolo
Rodola
'.
- Issue #15040: Close files in mailbox tests for PyPy compatibility.
- Issue #15040: Close files in mailbox tests for PyPy compatibility.
...
...
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