mirror of
https://github.com/yaml/pyyaml.git
synced 2025-10-19 11:03:18 +00:00
Share data files between Py2 and Py3 test suites.
This commit is contained in:
parent
ca836ef04d
commit
ab8d940469
598 changed files with 29 additions and 3034 deletions
|
@ -1,4 +1,5 @@
|
|||
include README LICENSE CHANGES setup.py
|
||||
recursive-include examples *.py *.cfg *.yaml
|
||||
recursive-include tests *.py
|
||||
recursive-include tests/data *
|
||||
recursive-include tests/lib *.py
|
||||
recursive-include tests/lib3 *.py
|
||||
|
|
4
Makefile
4
Makefile
|
@ -24,10 +24,10 @@ installext:
|
|||
${PYTHON} setup.py --with-libyaml install ${PARAMETERS}
|
||||
|
||||
test: build
|
||||
${PYTHON} tests/test_build.py ${TEST}
|
||||
${PYTHON} tests/lib/test_build.py ${TEST}
|
||||
|
||||
testext: buildext
|
||||
${PYTHON} tests/test_build_ext.py ${TEST}
|
||||
${PYTHON} tests/lib/test_build_ext.py ${TEST}
|
||||
|
||||
testall:
|
||||
${PYTHON} setup.py test
|
||||
|
|
4
setup.py
4
setup.py
|
@ -288,9 +288,9 @@ class test(Command):
|
|||
build_cmd.run()
|
||||
sys.path.insert(0, build_cmd.build_lib)
|
||||
if sys.version_info[0] < 3:
|
||||
sys.path.insert(0, 'tests')
|
||||
sys.path.insert(0, 'tests/lib')
|
||||
else:
|
||||
sys.path.insert(0, 'tests3')
|
||||
sys.path.insert(0, 'tests/lib3')
|
||||
import test_all
|
||||
test_all.main([])
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
[file, yaml.Loader, yaml.dump, abs, yaml.tokens]
|
||||
[str, yaml.Loader, yaml.dump, abs, yaml.tokens]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- !!python/name:file
|
||||
- !!python/name:str
|
||||
- !!python/name:yaml.Loader
|
||||
- !!python/name:yaml.dump
|
||||
- !!python/name:abs
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
dumper = yaml.Dumper(StringIO.StringIO())
|
||||
dumper = yaml.Dumper(StringIO())
|
||||
dumper.open()
|
||||
dumper.open()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
dumper = yaml.Dumper(StringIO.StringIO())
|
||||
dumper = yaml.Dumper(StringIO())
|
||||
dumper.open()
|
||||
dumper.close()
|
||||
dumper.open()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
dumper = yaml.Dumper(StringIO.StringIO())
|
||||
dumper = yaml.Dumper(StringIO())
|
||||
dumper.open()
|
||||
dumper.close()
|
||||
dumper.serialize(yaml.ScalarNode(tag='!foo', value='bar'))
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
dumper = yaml.Dumper(StringIO.StringIO())
|
||||
dumper = yaml.Dumper(StringIO())
|
||||
dumper.close()
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
dumper = yaml.Dumper(StringIO.StringIO())
|
||||
dumper = yaml.Dumper(StringIO())
|
||||
dumper.serialize(yaml.ScalarNode(tag='!foo', value='bar'))
|
||||
|
|
|
@ -23,6 +23,8 @@ def find_test_filenames(directory):
|
|||
for filename in os.listdir(directory):
|
||||
if os.path.isfile(os.path.join(directory, filename)):
|
||||
base, ext = os.path.splitext(filename)
|
||||
if base.endswith('-py3'):
|
||||
continue
|
||||
filenames.setdefault(base, []).append(ext)
|
||||
filenames = filenames.items()
|
||||
filenames.sort()
|
|
@ -50,7 +50,8 @@ test_emitter_error.unittest = ['.emitter-error']
|
|||
def test_dumper_error(error_filename, verbose=False):
|
||||
code = open(error_filename, 'rb').read()
|
||||
try:
|
||||
import yaml, StringIO
|
||||
import yaml
|
||||
from StringIO import StringIO
|
||||
exec code
|
||||
except yaml.YAMLError, exc:
|
||||
if verbose:
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
import sys, os, os.path, types, traceback, pprint
|
||||
|
||||
DATA = 'tests3/data'
|
||||
DATA = 'tests/data'
|
||||
|
||||
def find_test_functions(collections):
|
||||
if not isinstance(collections, list):
|
||||
|
@ -21,6 +21,8 @@ def find_test_filenames(directory):
|
|||
for filename in os.listdir(directory):
|
||||
if os.path.isfile(os.path.join(directory, filename)):
|
||||
base, ext = os.path.splitext(filename)
|
||||
if base.endswith('-py2'):
|
||||
continue
|
||||
filenames.setdefault(base, []).append(ext)
|
||||
filenames = sorted(filenames.items())
|
||||
return filenames
|
|
@ -12,8 +12,9 @@ def execute(code):
|
|||
|
||||
def _make_objects():
|
||||
global MyLoader, MyDumper, MyTestClass1, MyTestClass2, MyTestClass3, YAMLObject1, YAMLObject2, \
|
||||
AnObject, AnInstance, AState, ACustomState, NewArgs, NewArgsWithState, \
|
||||
Reduce, ReduceWithState, MyInt, MyList, MyDict, FixedOffset, execute
|
||||
AnObject, AnInstance, AState, ACustomState, InitArgs, InitArgsWithState, \
|
||||
NewArgs, NewArgsWithState, Reduce, ReduceWithState, MyInt, MyList, MyDict, \
|
||||
FixedOffset, execute
|
||||
|
||||
class MyLoader(yaml.Loader):
|
||||
pass
|
||||
|
@ -157,6 +158,10 @@ def _make_objects():
|
|||
def __setstate__(self, state):
|
||||
self.baz = state
|
||||
|
||||
InitArgs = NewArgs
|
||||
|
||||
InitArgsWithState = NewArgsWithState
|
||||
|
||||
class Reduce(AnObject):
|
||||
def __reduce__(self):
|
||||
return self.__class__, (self.foo, self.bar, self.baz)
|
|
@ -50,7 +50,8 @@ test_emitter_error.unittest = ['.emitter-error']
|
|||
def test_dumper_error(error_filename, verbose=False):
|
||||
code = open(error_filename, 'rb').read()
|
||||
try:
|
||||
import yaml, io
|
||||
import yaml
|
||||
from io import StringIO
|
||||
exec(code)
|
||||
except yaml.YAMLError as exc:
|
||||
if verbose:
|
|
@ -1 +0,0 @@
|
|||
[ [
|
|
@ -1,8 +0,0 @@
|
|||
- !StreamStart
|
||||
- !DocumentStart
|
||||
- !SequenceStart
|
||||
- !Scalar { anchor: 'myanchor', tag: '!mytag', value: 'data' }
|
||||
- !Alias { anchor: 'myanchor' }
|
||||
- !SequenceEnd
|
||||
- !DocumentEnd
|
||||
- !StreamEnd
|
|
@ -1,4 +0,0 @@
|
|||
- yes
|
||||
- NO
|
||||
- True
|
||||
- on
|
|
@ -1 +0,0 @@
|
|||
tag:yaml.org,2002:bool
|
|
@ -1 +0,0 @@
|
|||
{ foo:bar }
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"canonical": True,
|
||||
"answer": False,
|
||||
"logical": True,
|
||||
"option": True,
|
||||
"but": { "y": "is a string", "n": "is a string" },
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
canonical: yes
|
||||
answer: NO
|
||||
logical: True
|
||||
option: on
|
||||
|
||||
|
||||
but:
|
||||
y: is a string
|
||||
n: is a string
|
|
@ -1,10 +0,0 @@
|
|||
[
|
||||
MyTestClass1(x=1),
|
||||
MyTestClass1(x=1, y=2, z=3),
|
||||
MyTestClass2(x=10),
|
||||
MyTestClass2(x=10, y=20, z=30),
|
||||
MyTestClass3(x=1),
|
||||
MyTestClass3(x=1, y=2, z=3),
|
||||
MyTestClass3(x=1, y=2, z=3),
|
||||
YAMLObject1(my_parameter='foo', my_another_parameter=[1,2,3])
|
||||
]
|
|
@ -1,26 +0,0 @@
|
|||
---
|
||||
- !tag1
|
||||
x: 1
|
||||
- !tag1
|
||||
x: 1
|
||||
'y': 2
|
||||
z: 3
|
||||
- !tag2
|
||||
10
|
||||
- !tag2
|
||||
=: 10
|
||||
'y': 20
|
||||
z: 30
|
||||
- !tag3
|
||||
x: 1
|
||||
- !tag3
|
||||
x: 1
|
||||
'y': 2
|
||||
z: 3
|
||||
- !tag3
|
||||
=: 1
|
||||
'y': 2
|
||||
z: 3
|
||||
- !foo
|
||||
my-parameter: foo
|
||||
my-another-parameter: [1,2,3]
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"canonical": 685230.15,
|
||||
"exponential": 685230.15,
|
||||
"fixed": 685230.15,
|
||||
"sexagesimal": 685230.15,
|
||||
"negative infinity": -1e300000,
|
||||
"not a number": 1e300000/1e300000,
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
canonical: 6.8523015e+5
|
||||
exponential: 685.230_15e+03
|
||||
fixed: 685_230.15
|
||||
sexagesimal: 190:20:30.15
|
||||
negative infinity: -.inf
|
||||
not a number: .NaN
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"canonical": 685230,
|
||||
"decimal": 685230,
|
||||
"octal": 685230,
|
||||
"hexadecimal": 685230,
|
||||
"binary": 685230,
|
||||
"sexagesimal": 685230,
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
canonical: 685230
|
||||
decimal: +685_230
|
||||
octal: 02472256
|
||||
hexadecimal: 0x_0A_74_AE
|
||||
binary: 0b1010_0111_0100_1010_1110
|
||||
sexagesimal: 190:20:30
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"Block style":
|
||||
{ "Clark" : "Evans", "Brian" : "Ingerson", "Oren" : "Ben-Kiki" },
|
||||
"Flow style":
|
||||
{ "Clark" : "Evans", "Brian" : "Ingerson", "Oren" : "Ben-Kiki" },
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
# Unordered set of key: value pairs.
|
||||
Block style: !!map
|
||||
Clark : Evans
|
||||
Brian : Ingerson
|
||||
Oren : Ben-Kiki
|
||||
Flow style: !!map { Clark: Evans, Brian: Ingerson, Oren: Ben-Kiki }
|
|
@ -1,10 +0,0 @@
|
|||
[
|
||||
{ "x": 1, "y": 2 },
|
||||
{ "x": 0, "y": 2 },
|
||||
{ "r": 10 },
|
||||
{ "r": 1 },
|
||||
{ "x": 1, "y": 2, "r": 10, "label": "center/big" },
|
||||
{ "x": 1, "y": 2, "r": 10, "label": "center/big" },
|
||||
{ "x": 1, "y": 2, "r": 10, "label": "center/big" },
|
||||
{ "x": 1, "y": 2, "r": 10, "label": "center/big" },
|
||||
]
|
|
@ -1,27 +0,0 @@
|
|||
---
|
||||
- &CENTER { x: 1, 'y': 2 }
|
||||
- &LEFT { x: 0, 'y': 2 }
|
||||
- &BIG { r: 10 }
|
||||
- &SMALL { r: 1 }
|
||||
|
||||
# All the following maps are equal:
|
||||
|
||||
- # Explicit keys
|
||||
x: 1
|
||||
'y': 2
|
||||
r: 10
|
||||
label: center/big
|
||||
|
||||
- # Merge one map
|
||||
<< : *CENTER
|
||||
r: 10
|
||||
label: center/big
|
||||
|
||||
- # Merge multiple maps
|
||||
<< : [ *CENTER, *BIG ]
|
||||
label: center/big
|
||||
|
||||
- # Override
|
||||
<< : [ *BIG, *LEFT, *SMALL ]
|
||||
x: 1
|
||||
label: center/big
|
|
@ -1,13 +0,0 @@
|
|||
[
|
||||
None,
|
||||
{ "empty": None, "canonical": None, "english": None, None: "null key" },
|
||||
{
|
||||
"sparse": [
|
||||
None,
|
||||
"2nd entry",
|
||||
None,
|
||||
"4th entry",
|
||||
None,
|
||||
],
|
||||
},
|
||||
]
|
|
@ -1,18 +0,0 @@
|
|||
# A document may be null.
|
||||
---
|
||||
---
|
||||
# This mapping has four keys,
|
||||
# one has a value.
|
||||
empty:
|
||||
canonical: ~
|
||||
english: null
|
||||
~: null key
|
||||
---
|
||||
# This sequence has five
|
||||
# entries, two have values.
|
||||
sparse:
|
||||
- ~
|
||||
- 2nd entry
|
||||
-
|
||||
- 4th entry
|
||||
- Null
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"Bestiary": [
|
||||
("aardvark", "African pig-like ant eater. Ugly."),
|
||||
("anteater", "South-American ant eater. Two species."),
|
||||
("anaconda", "South-American constrictor snake. Scaly."),
|
||||
],
|
||||
"Numbers": [ ("one", 1), ("two", 2), ("three", 3) ],
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
# Explicitly typed ordered map (dictionary).
|
||||
Bestiary: !!omap
|
||||
- aardvark: African pig-like ant eater. Ugly.
|
||||
- anteater: South-American ant eater. Two species.
|
||||
- anaconda: South-American constrictor snake. Scaly.
|
||||
# Etc.
|
||||
# Flow style
|
||||
Numbers: !!omap [ one: 1, two: 2, three : 3 ]
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"Block tasks": [
|
||||
("meeting", "with team."),
|
||||
("meeting", "with boss."),
|
||||
("break", "lunch."),
|
||||
("meeting", "with client."),
|
||||
],
|
||||
"Flow tasks": [ ("meeting", "with team"), ("meeting", "with boss") ],
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue