diff options
Diffstat (limited to 'tests3')
-rw-r--r-- | tests3/data/construct-python-bytes.code | 1 | ||||
-rw-r--r-- | tests3/data/construct-python-bytes.data | 1 | ||||
-rw-r--r-- | tests3/data/construct-python-long-short.code | 2 | ||||
-rw-r--r-- | tests3/data/construct-python-name-module.code | 2 | ||||
-rw-r--r-- | tests3/data/construct-python-name-module.data | 2 | ||||
-rw-r--r-- | tests3/data/construct-python-object.code | 3 | ||||
-rw-r--r-- | tests3/data/construct-python-object.data | 3 | ||||
-rw-r--r-- | tests3/data/construct-python-str-utf8.code | 2 | ||||
-rw-r--r-- | tests3/data/construct-python-unicode-ascii.code | 2 | ||||
-rw-r--r-- | tests3/data/construct-python-unicode-utf8.code | 2 | ||||
-rw-r--r-- | tests3/data/construct-str-utf8.code | 2 | ||||
-rw-r--r-- | tests3/data/recursive-set.recursive | 4 | ||||
-rw-r--r-- | tests3/test_constructor.py | 22 | ||||
-rw-r--r-- | tests3/test_recursive.py | 5 |
14 files changed, 16 insertions, 37 deletions
diff --git a/tests3/data/construct-python-bytes.code b/tests3/data/construct-python-bytes.code new file mode 100644 index 0000000..b9051d8 --- /dev/null +++ b/tests3/data/construct-python-bytes.code @@ -0,0 +1 @@ +b'some binary data' diff --git a/tests3/data/construct-python-bytes.data b/tests3/data/construct-python-bytes.data new file mode 100644 index 0000000..9528725 --- /dev/null +++ b/tests3/data/construct-python-bytes.data @@ -0,0 +1 @@ +--- !!python/bytes 'c29tZSBiaW5hcnkgZGF0YQ==' diff --git a/tests3/data/construct-python-long-short.code b/tests3/data/construct-python-long-short.code index fafc3f1..190a180 100644 --- a/tests3/data/construct-python-long-short.code +++ b/tests3/data/construct-python-long-short.code @@ -1 +1 @@ -123L +123 diff --git a/tests3/data/construct-python-name-module.code b/tests3/data/construct-python-name-module.code index 8f93503..6f39148 100644 --- a/tests3/data/construct-python-name-module.code +++ b/tests3/data/construct-python-name-module.code @@ -1 +1 @@ -[file, yaml.Loader, yaml.dump, abs, yaml.tokens] +[str, yaml.Loader, yaml.dump, abs, yaml.tokens] diff --git a/tests3/data/construct-python-name-module.data b/tests3/data/construct-python-name-module.data index c8f8036..f0c9712 100644 --- a/tests3/data/construct-python-name-module.data +++ b/tests3/data/construct-python-name-module.data @@ -1,4 +1,4 @@ -- !!python/name:file +- !!python/name:str - !!python/name:yaml.Loader - !!python/name:yaml.dump - !!python/name:abs diff --git a/tests3/data/construct-python-object.code b/tests3/data/construct-python-object.code index 7f1edf1..bfc840a 100644 --- a/tests3/data/construct-python-object.code +++ b/tests3/data/construct-python-object.code @@ -8,9 +8,6 @@ AnInstance(1, 'two', [3,3,3]), AState(1, 'two', [3,3,3]), ACustomState(1, 'two', [3,3,3]), -InitArgs(1, 'two', [3,3,3]), -InitArgsWithState(1, 'two', [3,3,3]), - NewArgs(1, 'two', [3,3,3]), NewArgsWithState(1, 'two', [3,3,3]), diff --git a/tests3/data/construct-python-object.data b/tests3/data/construct-python-object.data index bce8b2e..6f7a7ce 100644 --- a/tests3/data/construct-python-object.data +++ b/tests3/data/construct-python-object.data @@ -7,9 +7,6 @@ - !!python/object:test_constructor.AState { _foo: 1, _bar: two, _baz: [3,3,3] } - !!python/object/new:test_constructor.ACustomState { state: !!python/tuple [1, two, [3,3,3]] } -- !!python/object/new:test_constructor.InitArgs [1, two, [3,3,3]] -- !!python/object/new:test_constructor.InitArgsWithState { args: [1, two], state: [3,3,3] } - - !!python/object/new:test_constructor.NewArgs [1, two, [3,3,3]] - !!python/object/new:test_constructor.NewArgsWithState { args: [1, two], state: [3,3,3] } diff --git a/tests3/data/construct-python-str-utf8.code b/tests3/data/construct-python-str-utf8.code index 47b28ab..9f66032 100644 --- a/tests3/data/construct-python-str-utf8.code +++ b/tests3/data/construct-python-str-utf8.code @@ -1 +1 @@ -u'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430'.encode('utf-8') +'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' diff --git a/tests3/data/construct-python-unicode-ascii.code b/tests3/data/construct-python-unicode-ascii.code index d4cd82c..d9d62f6 100644 --- a/tests3/data/construct-python-unicode-ascii.code +++ b/tests3/data/construct-python-unicode-ascii.code @@ -1 +1 @@ -u"ascii string" +"ascii string" diff --git a/tests3/data/construct-python-unicode-utf8.code b/tests3/data/construct-python-unicode-utf8.code index 2793ac7..9f66032 100644 --- a/tests3/data/construct-python-unicode-utf8.code +++ b/tests3/data/construct-python-unicode-utf8.code @@ -1 +1 @@ -u'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' +'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' diff --git a/tests3/data/construct-str-utf8.code b/tests3/data/construct-str-utf8.code index 2793ac7..9f66032 100644 --- a/tests3/data/construct-str-utf8.code +++ b/tests3/data/construct-str-utf8.code @@ -1 +1 @@ -u'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' +'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' diff --git a/tests3/data/recursive-set.recursive b/tests3/data/recursive-set.recursive index 457c50d..d1a7ca3 100644 --- a/tests3/data/recursive-set.recursive +++ b/tests3/data/recursive-set.recursive @@ -1,7 +1,3 @@ -try: - set -except NameError: - from sets import Set as set value = set() value.add(AnInstance(foo=value, bar=value)) value.add(AnInstance(foo=value, bar=value)) diff --git a/tests3/test_constructor.py b/tests3/test_constructor.py index c9c7f55..c632b4f 100644 --- a/tests3/test_constructor.py +++ b/tests3/test_constructor.py @@ -6,14 +6,14 @@ import datetime import yaml.tokens def execute(code): + global value exec(code) return value def _make_objects(): global MyLoader, MyDumper, MyTestClass1, MyTestClass2, MyTestClass3, YAMLObject1, YAMLObject2, \ - AnObject, AnInstance, AState, ACustomState, InitArgs, InitArgsWithState, \ - NewArgs, NewArgsWithState, Reduce, ReduceWithState, MyInt, MyList, MyDict, \ - FixedOffset, execute + AnObject, AnInstance, AState, ACustomState, NewArgs, NewArgsWithState, \ + Reduce, ReduceWithState, MyInt, MyList, MyDict, FixedOffset, execute class MyLoader(yaml.Loader): pass @@ -99,7 +99,7 @@ def _make_objects(): else: return False - class AnObject(object): + class AnObject: def __new__(cls, foo=None, bar=None, baz=None): self = object.__new__(cls) self.foo = foo @@ -143,20 +143,6 @@ def _make_objects(): def __setstate__(self, state): self.foo, self.bar, self.baz = state - class InitArgs(AnInstance): - def __getinitargs__(self): - return (self.foo, self.bar, self.baz) - def __getstate__(self): - return {} - - class InitArgsWithState(AnInstance): - def __getinitargs__(self): - return (self.foo, self.bar) - def __getstate__(self): - return self.baz - def __setstate__(self, state): - self.baz = state - class NewArgs(AnObject): def __getnewargs__(self): return (self.foo, self.bar, self.baz) diff --git a/tests3/test_recursive.py b/tests3/test_recursive.py index 1ab79bd..321a75f 100644 --- a/tests3/test_recursive.py +++ b/tests3/test_recursive.py @@ -23,8 +23,9 @@ class AnInstanceWithState(AnInstance): self.foo, self.bar = state['attributes'] def test_recursive(recursive_filename, verbose=False): - exec(open(recursive_filename, 'rb').read()) - value1 = value + context = globals().copy() + exec(open(recursive_filename, 'rb').read(), context) + value1 = context['value'] output1 = None value2 = None output2 = None |