From dce10fcff1de54121fb8b440b883ef5d3fe2f96a Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Fri, 3 Aug 2018 22:14:57 +0200 Subject: Apply oitnb and mypy 0.620, then make everything work again --- _test/lib/canonical.py | 60 +++++++++++----------- _test/lib/test_all.py | 2 + _test/lib/test_appliance.py | 27 +++++----- _test/lib/test_build.py | 7 ++- _test/lib/test_build_ext.py | 7 ++- _test/lib/test_canonical.py | 3 +- _test/lib/test_constructor.py | 80 ++++++++++++++++++------------ _test/lib/test_emitter.py | 42 ++++++++++------ _test/lib/test_errors.py | 26 +++++----- _test/lib/test_input_output.py | 78 +++++++++++++++++++---------- _test/lib/test_mark.py | 4 +- _test/lib/test_reader.py | 5 +- _test/lib/test_recursive.py | 15 +++--- _test/lib/test_representer.py | 19 ++++--- _test/lib/test_resolver.py | 28 ++++++----- _test/lib/test_structure.py | 36 ++++++++------ _test/lib/test_tokens.py | 8 +-- _test/lib/test_yaml.py | 23 ++++----- _test/lib/test_yaml_ext.py | 110 +++++++++++++++++++++++++++++------------ 19 files changed, 352 insertions(+), 228 deletions(-) (limited to '_test/lib') diff --git a/_test/lib/canonical.py b/_test/lib/canonical.py index 64f3153..af2c3cf 100644 --- a/_test/lib/canonical.py +++ b/_test/lib/canonical.py @@ -11,7 +11,6 @@ class CanonicalError(ruamel.yaml.YAMLError): class CanonicalScanner: - def __init__(self, data): try: if PY3: @@ -20,7 +19,7 @@ class CanonicalScanner: else: data = unicode(data, 'utf-8') # NOQA except UnicodeDecodeError: - raise CanonicalError("utf-8 stream is expected") + raise CanonicalError('utf-8 stream is expected') self.data = data + u'\0' self.index = 0 self.tokens = [] @@ -48,7 +47,7 @@ class CanonicalScanner: self.scan() token = self.tokens.pop(0) if choice and not isinstance(token, choice): - raise CanonicalError("unexpected token " + repr(token)) + raise CanonicalError('unexpected token ' + repr(token)) return token def get_token_value(self): @@ -65,7 +64,7 @@ class CanonicalScanner: break elif ch == u'%': self.tokens.append(self.scan_directive()) - elif ch == u'-' and self.data[self.index:self.index + 3] == u'---': + elif ch == u'-' and self.data[self.index : self.index + 3] == u'---': self.index += 3 self.tokens.append(ruamel.yaml.DocumentStartToken(None, None)) elif ch == u'[': @@ -96,18 +95,20 @@ class CanonicalScanner: elif ch == u'"': self.tokens.append(self.scan_scalar()) else: - raise CanonicalError("invalid token") + raise CanonicalError('invalid token') self.scanned = True DIRECTIVE = u'%YAML 1.1' def scan_directive(self): - if self.data[self.index:self.index + len(self.DIRECTIVE)] == self.DIRECTIVE and \ - self.data[self.index + len(self.DIRECTIVE)] in u' \n\0': + if ( + self.data[self.index : self.index + len(self.DIRECTIVE)] == self.DIRECTIVE + and self.data[self.index + len(self.DIRECTIVE)] in u' \n\0' + ): self.index += len(self.DIRECTIVE) return ruamel.yaml.DirectiveToken('YAML', (1, 1), None, None) else: - raise CanonicalError("invalid directive") + raise CanonicalError('invalid directive') def scan_alias(self): if self.data[self.index] == u'*': @@ -118,7 +119,7 @@ class CanonicalScanner: start = self.index while self.data[self.index] not in u', \n\0': self.index += 1 - value = self.data[start:self.index] + value = self.data[start : self.index] return TokenClass(value, None, None) def scan_tag(self): @@ -126,7 +127,7 @@ class CanonicalScanner: start = self.index while self.data[self.index] not in u' \n\0': self.index += 1 - value = self.data[start:self.index] + value = self.data[start : self.index] if not value: value = u'!' elif value[0] == u'!': @@ -137,15 +138,11 @@ class CanonicalScanner: value = u'!' + value return ruamel.yaml.TagToken(value, None, None) - QUOTE_CODES = { - 'x': 2, - 'u': 4, - 'U': 8, - } + QUOTE_CODES = {'x': 2, 'u': 4, 'U': 8} QUOTE_REPLACES = { u'\\': u'\\', - u'\"': u'\"', + u'"': u'"', u' ': u' ', u'a': u'\x07', u'b': u'\x08', @@ -160,7 +157,6 @@ class CanonicalScanner: u'P': u'\u2029', u'_': u'_', u'0': u'\x00', - } def scan_scalar(self): @@ -171,7 +167,7 @@ class CanonicalScanner: while self.data[self.index] != u'"': if self.data[self.index] == u'\\': ignore_spaces = False - chunks.append(self.data[start:self.index]) + chunks.append(self.data[start : self.index]) self.index += 1 ch = self.data[self.index] self.index += 1 @@ -179,16 +175,16 @@ class CanonicalScanner: ignore_spaces = True elif ch in self.QUOTE_CODES: length = self.QUOTE_CODES[ch] - code = int(self.data[self.index:self.index + length], 16) + code = int(self.data[self.index : self.index + length], 16) chunks.append(unichr(code)) self.index += length else: if ch not in self.QUOTE_REPLACES: - raise CanonicalError("invalid escape code") + raise CanonicalError('invalid escape code') chunks.append(self.QUOTE_REPLACES[ch]) start = self.index elif self.data[self.index] == u'\n': - chunks.append(self.data[start:self.index]) + chunks.append(self.data[start : self.index]) chunks.append(u' ') self.index += 1 start = self.index @@ -199,9 +195,9 @@ class CanonicalScanner: else: ignore_spaces = False self.index += 1 - chunks.append(self.data[start:self.index]) + chunks.append(self.data[start : self.index]) self.index += 1 - return ruamel.yaml.ScalarToken(u''.join(chunks), False, None, None) + return ruamel.yaml.ScalarToken("".join(chunks), False, None, None) def find_token(self): found = False @@ -233,7 +229,7 @@ class CanonicalParser: if self.check_token(ruamel.yaml.DirectiveToken, ruamel.yaml.DocumentStartToken): self.parse_document() else: - raise CanonicalError("document is expected, got " + repr(self.tokens[0])) + raise CanonicalError('document is expected, got ' + repr(self.tokens[0])) self.get_token(ruamel.yaml.StreamEndToken) self.events.append(ruamel.yaml.StreamEndEvent(None, None)) @@ -259,8 +255,11 @@ class CanonicalParser: if self.check_token(ruamel.yaml.TagToken): tag = self.get_token_value() if self.check_token(ruamel.yaml.ScalarToken): - self.events.append(ruamel.yaml.ScalarEvent(anchor, tag, (False, False), - self.get_token_value(), None, None)) + self.events.append( + ruamel.yaml.ScalarEvent( + anchor, tag, (False, False), self.get_token_value(), None, None + ) + ) elif self.check_token(ruamel.yaml.FlowSequenceStartToken): self.events.append(ruamel.yaml.SequenceStartEvent(anchor, tag, None, None)) self.parse_sequence() @@ -268,8 +267,9 @@ class CanonicalParser: self.events.append(ruamel.yaml.MappingStartEvent(anchor, tag, None, None)) self.parse_mapping() else: - raise CanonicalError("SCALAR, '[', or '{' is expected, got " + - repr(self.tokens[0])) + raise CanonicalError( + "SCALAR, '[', or '{' is expected, got " + repr(self.tokens[0]) + ) # sequence: SEQUENCE-START (node (ENTRY node)*)? ENTRY? SEQUENCE-END def parse_sequence(self): @@ -328,9 +328,7 @@ class CanonicalParser: return self.events[0] -class CanonicalLoader(CanonicalScanner, CanonicalParser, - Composer, Constructor, Resolver): - +class CanonicalLoader(CanonicalScanner, CanonicalParser, Composer, Constructor, Resolver): def __init__(self, stream): if hasattr(stream, 'read'): stream = stream.read() diff --git a/_test/lib/test_all.py b/_test/lib/test_all.py index 9e951eb..8099ec8 100644 --- a/_test/lib/test_all.py +++ b/_test/lib/test_all.py @@ -7,9 +7,11 @@ import test_appliance def main(args=None): collections = [] import test_yaml + collections.append(test_yaml) if ruamel.yaml.__with_libyaml__: import test_yaml_ext + collections.append(test_yaml_ext) test_appliance.run(collections, args) diff --git a/_test/lib/test_appliance.py b/_test/lib/test_appliance.py index a96052d..137c271 100644 --- a/_test/lib/test_appliance.py +++ b/_test/lib/test_appliance.py @@ -44,31 +44,34 @@ def find_test_filenames(directory): def parse_arguments(args): """""" - parser = argparse.ArgumentParser(usage=""" run the yaml tests. By default + parser = argparse.ArgumentParser( + usage=""" run the yaml tests. By default all functions on all appropriate test_files are run. Functions have unittest attributes that determine the required extensions to filenames that need to be available in order to run that test. E.g.\n\n python test_yaml.py test_constructor_types\n python test_yaml.py --verbose test_tokens spec-02-05\n\n The presence of an extension in the .skip attribute of a function - disables the test for that function.""") + disables the test for that function.""" + ) # ToDo: make into int and test > 0 in functions parser.add_argument( - '--verbose', '-v', action="store_true", + '--verbose', + '-v', + action='store_true', default='YAML_TEST_VERBOSE' in os.environ, - help="set verbosity output", + help='set verbosity output', ) parser.add_argument( - '--list-functions', action="store_true", + '--list-functions', + action='store_true', help="""list all functions with required file extensions for test files - """ - ) - parser.add_argument( - 'function', nargs='?', - help="""restrict function to run""", + """, ) + parser.add_argument('function', nargs='?', help="""restrict function to run""") parser.add_argument( - 'filenames', nargs='*', + 'filenames', + nargs='*', help="""basename of filename set, extensions (.code, .data) have to be a superset of those in the unittest attribute of the selected function""", @@ -194,7 +197,7 @@ def run(collections, args=None): results = [] for function in test_functions: if include_functions and function.__name__ not in include_functions: - continue + continue if function.unittest: for base, exts in test_filenames: if include_filenames and base not in include_filenames: diff --git a/_test/lib/test_build.py b/_test/lib/test_build.py index 5d19e3a..f7837eb 100644 --- a/_test/lib/test_build.py +++ b/_test/lib/test_build.py @@ -3,11 +3,14 @@ if __name__ == '__main__': import sys import os import distutils.util + build_lib = 'build/lib' - build_lib_ext = os.path.join('build', 'lib.%s-%s' % (distutils.util.get_platform(), - sys.version[0:3])) + build_lib_ext = os.path.join( + 'build', 'lib.%s-%s' % (distutils.util.get_platform(), sys.version[0:3]) + ) sys.path.insert(0, build_lib) sys.path.insert(0, build_lib_ext) import test_yaml import test_appliance + test_appliance.run(test_yaml) diff --git a/_test/lib/test_build_ext.py b/_test/lib/test_build_ext.py index 92d927e..1a58fd2 100644 --- a/_test/lib/test_build_ext.py +++ b/_test/lib/test_build_ext.py @@ -4,11 +4,14 @@ if __name__ == '__main__': import sys import os import distutils.util + build_lib = 'build/lib' - build_lib_ext = os.path.join('build', 'lib.%s-%s' % (distutils.util.get_platform(), - sys.version[0:3])) + build_lib_ext = os.path.join( + 'build', 'lib.%s-%s' % (distutils.util.get_platform(), sys.version[0:3]) + ) sys.path.insert(0, build_lib) sys.path.insert(0, build_lib_ext) import test_yaml_ext import test_appliance + test_appliance.run(test_yaml_ext) diff --git a/_test/lib/test_canonical.py b/_test/lib/test_canonical.py index 682f6ab..48a1764 100644 --- a/_test/lib/test_canonical.py +++ b/_test/lib/test_canonical.py @@ -40,7 +40,7 @@ def test_canonical_error(data_filename, canonical_filename, verbose=False): if verbose: print(exc) else: - raise AssertionError("expected an exception") + raise AssertionError('expected an exception') test_canonical_error.unittest = ['.data', '.canonical'] @@ -48,4 +48,5 @@ test_canonical_error.skip = ['.empty'] if __name__ == '__main__': import test_appliance + test_appliance.run(globals()) diff --git a/_test/lib/test_constructor.py b/_test/lib/test_constructor.py index d10ea4d..a66ff1a 100644 --- a/_test/lib/test_constructor.py +++ b/_test/lib/test_constructor.py @@ -6,6 +6,7 @@ import pprint from ruamel.yaml.compat import PY2 import datetime + try: set except NameError: @@ -20,10 +21,7 @@ def execute(code): 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, today, execute + global MyLoader, MyDumper, MyTestClass1, MyTestClass2, MyTestClass3, YAMLobject1, YAMLobject2, AnObject, AnInstance, AState, ACustomState, InitArgs, InitArgsWithState, NewArgs, NewArgsWithState, Reduce, ReduceWithState, MyInt, MyList, MyDict, FixedOffset, today, execute class MyLoader(ruamel.yaml.Loader): pass @@ -48,27 +46,29 @@ def _make_objects(): return MyTestClass1(**mapping) def represent1(representer, native): - return representer.represent_mapping("!tag1", native.__dict__) + return representer.represent_mapping('!tag1', native.__dict__) - ruamel.yaml.add_constructor("!tag1", construct1, Loader=MyLoader) + ruamel.yaml.add_constructor('!tag1', construct1, Loader=MyLoader) ruamel.yaml.add_representer(MyTestClass1, represent1, Dumper=MyDumper) class MyTestClass2(MyTestClass1, ruamel.yaml.YAMLObject): ruamel.yaml.loader = MyLoader ruamel.yaml.dumper = MyDumper - ruamel.yaml.tag = "!tag2" + ruamel.yaml.tag = '!tag2' def from_yaml(cls, constructor, node): x = constructor.construct_yaml_int(node) return cls(x=x) + from_yaml = classmethod(from_yaml) def to_yaml(cls, representer, native): return representer.represent_scalar(cls.yaml_tag, str(native.x)) + to_yaml = classmethod(to_yaml) class MyTestClass3(MyTestClass2): - ruamel.yaml.tag = "!tag3" + ruamel.yaml.tag = '!tag3' def from_yaml(cls, constructor, node): mapping = constructor.construct_mapping(node) @@ -77,10 +77,12 @@ def _make_objects(): del mapping['='] mapping['x'] = x return cls(**mapping) + from_yaml = classmethod(from_yaml) def to_yaml(cls, representer, native): return representer.represent_mapping(cls.yaml_tag, native.__dict__) + to_yaml = classmethod(to_yaml) class YAMLobject1(ruamel.yaml.YAMLObject): @@ -131,12 +133,17 @@ def _make_objects(): return self def __cmp__(self, other): - return cmp((type(self), self.foo, self.bar, self.baz), # NOQA - (type(other), other.foo, other.bar, other.baz)) + return cmp( + (type(self), self.foo, self.bar, self.baz), # NOQA + (type(other), other.foo, other.bar, other.baz), + ) def __eq__(self, other): - return type(self) is type(other) and \ - (self.foo, self.bar, self.baz) == (other.foo, other.bar, other.baz) + return type(self) is type(other) and (self.foo, self.bar, self.baz) == ( + other.foo, + other.bar, + other.baz, + ) class AnInstance: def __init__(self, foo=None, bar=None, baz=None): @@ -145,20 +152,21 @@ def _make_objects(): self.baz = baz def __cmp__(self, other): - return cmp((type(self), self.foo, self.bar, self.baz), # NOQA - (type(other), other.foo, other.bar, other.baz)) + return cmp( + (type(self), self.foo, self.bar, self.baz), # NOQA + (type(other), other.foo, other.bar, other.baz), + ) def __eq__(self, other): - return type(self) is type(other) and \ - (self.foo, self.bar, self.baz) == (other.foo, other.bar, other.baz) + return type(self) is type(other) and (self.foo, self.bar, self.baz) == ( + other.foo, + other.bar, + other.baz, + ) class AState(AnInstance): def __getstate__(self): - return { - '_foo': self.foo, - '_bar': self.bar, - '_baz': self.baz, - } + return {'_foo': self.foo, '_bar': self.bar, '_baz': self.baz} def __setstate__(self, state): self.foo = state['_foo'] @@ -259,6 +267,7 @@ try: from ruamel.ordereddict import ordereddict except ImportError: from collections import OrderedDict + # to get the right name import ... as ordereddict doesn't do that class ordereddict(OrderedDict): @@ -277,7 +286,7 @@ def _serialize_value(data): for key, value in data.items(): key = _serialize_value(key) value = _serialize_value(value) - items.append("%s: %s" % (key, value)) + items.append('%s: %s' % (key, value)) items.sort() return '{%s}' % ', '.join(items) elif isinstance(data, datetime.datetime): @@ -308,16 +317,16 @@ def test_constructor_types(data_filename, code_filename, verbose=False): pass # print('native1', native1) if verbose: - print("SERIALIZED NATIVE1:") + print('SERIALIZED NATIVE1:') print(_serialize_value(native1)) - print("SERIALIZED NATIVE2:") + print('SERIALIZED NATIVE2:') print(_serialize_value(native2)) assert _serialize_value(native1) == _serialize_value(native2), (native1, native2) finally: if verbose: - print("NATIVE1:") + print('NATIVE1:') pprint.pprint(native1) - print("NATIVE2:") + print('NATIVE2:') pprint.pprint(native2) @@ -327,23 +336,28 @@ test_constructor_types.unittest = ['.data', '.code'] def test_roundtrip_data(code_filename, roundtrip_filename, verbose=False): _make_objects() with open(code_filename, 'rb') as fp0: - value1 = fp0 .read() + value1 = fp0.read() native2 = list(ruamel.yaml.load_all(value1, Loader=MyLoader)) if len(native2) == 1: native2 = native2[0] try: - value2 = ruamel.yaml.dump(native2, Dumper=MyDumper, default_flow_style=False, - allow_unicode=True, encoding='utf-8') + value2 = ruamel.yaml.dump( + native2, + Dumper=MyDumper, + default_flow_style=False, + allow_unicode=True, + encoding='utf-8', + ) # value2 += x if verbose: - print("SERIALIZED NATIVE1:") + print('SERIALIZED NATIVE1:') print(value1) - print("SERIALIZED NATIVE2:") + print('SERIALIZED NATIVE2:') print(value2) assert value1 == value2, (value1, value2) finally: if verbose: - print("NATIVE2:") + print('NATIVE2:') pprint.pprint(native2) @@ -353,6 +367,8 @@ test_roundtrip_data.unittest = ['.data', '.roundtrip'] if __name__ == '__main__': import sys import test_constructor # NOQA + sys.modules['test_constructor'] = sys.modules['__main__'] import test_appliance + test_appliance.run(globals()) diff --git a/_test/lib/test_emitter.py b/_test/lib/test_emitter.py index 4b6fb76..fbdbb79 100644 --- a/_test/lib/test_emitter.py +++ b/_test/lib/test_emitter.py @@ -23,7 +23,7 @@ def test_emitter_on_data(data_filename, canonical_filename, verbose=False): events = list(yaml.parse(fp0)) output = yaml.emit(events) if verbose: - print("OUTPUT:") + print('OUTPUT:') print(output) new_events = list(yaml.parse(output)) _compare_events(events, new_events) @@ -38,7 +38,7 @@ def test_emitter_on_canonical(canonical_filename, verbose=False): for canonical in [False, True]: output = yaml.emit(events, canonical=canonical) if verbose: - print("OUTPUT (canonical=%s):" % canonical) + print('OUTPUT (canonical=%s):' % canonical) print(output) new_events = list(yaml.parse(output)) _compare_events(events, new_events) @@ -52,23 +52,28 @@ def test_emitter_styles(data_filename, canonical_filename, verbose=False): with open(filename, 'rb') as fp0: events = list(yaml.parse(fp0)) for flow_style in [False, True]: - for style in ['|', '>', '"', '\'', '']: + for style in ['|', '>', '"', "'", ""]: styled_events = [] for event in events: if isinstance(event, yaml.ScalarEvent): - event = yaml.ScalarEvent(event.anchor, event.tag, - event.implicit, event.value, style=style) + event = yaml.ScalarEvent( + event.anchor, event.tag, event.implicit, event.value, style=style + ) elif isinstance(event, yaml.SequenceStartEvent): - event = yaml.SequenceStartEvent(event.anchor, event.tag, - event.implicit, flow_style=flow_style) + event = yaml.SequenceStartEvent( + event.anchor, event.tag, event.implicit, flow_style=flow_style + ) elif isinstance(event, yaml.MappingStartEvent): - event = yaml.MappingStartEvent(event.anchor, event.tag, - event.implicit, flow_style=flow_style) + event = yaml.MappingStartEvent( + event.anchor, event.tag, event.implicit, flow_style=flow_style + ) styled_events.append(event) output = yaml.emit(styled_events) if verbose: - print("OUTPUT (filename=%r, flow_style=%r, style=%r)" % - (filename, flow_style, style)) + print( + 'OUTPUT (filename=%r, flow_style=%r, style=%r)' + % (filename, flow_style, style) + ) print(output) new_events = list(yaml.parse(output)) _compare_events(events, new_events) @@ -78,15 +83,18 @@ test_emitter_styles.unittest = ['.data', '.canonical'] class EventsLoader(yaml.Loader): - def construct_event(self, node): if isinstance(node, yaml.ScalarNode): mapping = {} else: mapping = self.construct_mapping(node) class_name = str(node.tag[1:]) + 'Event' - if class_name in ['AliasEvent', 'ScalarEvent', 'SequenceStartEvent', - 'MappingStartEvent']: + if class_name in [ + 'AliasEvent', + 'ScalarEvent', + 'SequenceStartEvent', + 'MappingStartEvent', + ]: mapping.setdefault('anchor', None) if class_name in ['ScalarEvent', 'SequenceStartEvent', 'MappingStartEvent']: mapping.setdefault('tag', None) @@ -94,10 +102,11 @@ class EventsLoader(yaml.Loader): mapping.setdefault('implicit', True) if class_name == 'ScalarEvent': mapping.setdefault('implicit', (False, True)) - mapping.setdefault('value', '') + mapping.setdefault('value', "") value = getattr(yaml, class_name)(**mapping) return value + # if Loader is not a composite, add this function # EventsLoader.add_constructor = yaml.constructor.Constructor.add_constructor @@ -110,7 +119,7 @@ def test_emitter_events(events_filename, verbose=False): events = list(yaml.load(fp0, Loader=EventsLoader)) output = yaml.emit(events) if verbose: - print("OUTPUT:") + print('OUTPUT:') print(output) new_events = list(yaml.parse(output)) _compare_events(events, new_events) @@ -118,4 +127,5 @@ def test_emitter_events(events_filename, verbose=False): if __name__ == '__main__': import test_appliance + test_appliance.run(globals()) diff --git a/_test/lib/test_errors.py b/_test/lib/test_errors.py index cfaa000..b43540c 100644 --- a/_test/lib/test_errors.py +++ b/_test/lib/test_errors.py @@ -4,6 +4,7 @@ from __future__ import print_function import ruamel.yaml as yaml import test_emitter import warnings + warnings.simplefilter('ignore', yaml.error.UnsafeLoaderWarning) @@ -13,9 +14,9 @@ def test_loader_error(error_filename, verbose=False): list(yaml.load_all(fp0)) except yaml.YAMLError as exc: if verbose: - print("%s:" % exc.__class__.__name__, exc) + print('%s:' % exc.__class__.__name__, exc) else: - raise AssertionError("expected an exception") + raise AssertionError('expected an exception') test_loader_error.unittest = ['.loader-error'] @@ -27,9 +28,9 @@ def test_loader_error_string(error_filename, verbose=False): list(yaml.load_all(fp0.read())) except yaml.YAMLError as exc: if verbose: - print("%s:" % exc.__class__.__name__, exc) + print('%s:' % exc.__class__.__name__, exc) else: - raise AssertionError("expected an exception") + raise AssertionError('expected an exception') test_loader_error_string.unittest = ['.loader-error'] @@ -41,9 +42,9 @@ def test_loader_error_single(error_filename, verbose=False): yaml.load(fp0.read()) except yaml.YAMLError as exc: if verbose: - print("%s:" % exc.__class__.__name__, exc) + print('%s:' % exc.__class__.__name__, exc) else: - raise AssertionError("expected an exception") + raise AssertionError('expected an exception') test_loader_error_single.unittest = ['.single-loader-error'] @@ -51,15 +52,14 @@ test_loader_error_single.unittest = ['.single-loader-error'] def test_emitter_error(error_filename, verbose=False): with open(error_filename, 'rb') as fp0: - events = list(yaml.load(fp0, - Loader=test_emitter.EventsLoader)) + events = list(yaml.load(fp0, Loader=test_emitter.EventsLoader)) try: yaml.emit(events) except yaml.YAMLError as exc: if verbose: - print("%s:" % exc.__class__.__name__, exc) + print('%s:' % exc.__class__.__name__, exc) else: - raise AssertionError("expected an exception") + raise AssertionError('expected an exception') test_emitter_error.unittest = ['.emitter-error'] @@ -70,16 +70,18 @@ def test_dumper_error(error_filename, verbose=False): code = fp0.read() try: import yaml + exec(code) except yaml.YAMLError as exc: if verbose: - print("%s:" % exc.__class__.__name__, exc) + print('%s:' % exc.__class__.__name__, exc) else: - raise AssertionError("expected an exception") + raise AssertionError('expected an exception') test_dumper_error.unittest = ['.dumper-error'] if __name__ == '__main__': import test_appliance + test_appliance.run(globals()) diff --git a/_test/lib/test_input_output.py b/_test/lib/test_input_output.py index 27f7aed..c36477f 100644 --- a/_test/lib/test_input_output.py +++ b/_test/lib/test_input_output.py @@ -9,6 +9,7 @@ import os.path from ruamel.yaml.compat import PY2, PY3, StringIO, BytesIO if PY2: + def _unicode_open(file, encoding, errors='strict'): info = codecs.lookup(encoding) if isinstance(info, tuple): @@ -21,7 +22,9 @@ if PY2: srw.encoding = encoding return srw + if PY3: + def test_unicode_input(unicode_filename, verbose=False): with open(unicode_filename, 'rb') as fp: data = fp.read().decode('utf-8') @@ -30,64 +33,77 @@ if PY3: assert output == value, (output, value) output = yaml.load(StringIO(data)) assert output == value, (output, value) - for input in [data.encode('utf-8'), - codecs.BOM_UTF8 + data.encode('utf-8'), - codecs.BOM_UTF16_BE + data.encode('utf-16-be'), - codecs.BOM_UTF16_LE + data.encode('utf-16-le')]: + for input in [ + data.encode('utf-8'), + codecs.BOM_UTF8 + data.encode('utf-8'), + codecs.BOM_UTF16_BE + data.encode('utf-16-be'), + codecs.BOM_UTF16_LE + data.encode('utf-16-le'), + ]: if verbose: - print("INPUT:", repr(input[:10]), "...") + print('INPUT:', repr(input[:10]), '...') output = yaml.load(input) assert output == value, (output, value) output = yaml.load(BytesIO(input)) assert output == value, (output, value) + + else: + def test_unicode_input(unicode_filename, verbose=False): with open(unicode_filename, 'rb') as fp: data = fp.read().decode('utf-8') value = ' '.join(data.split()) output = yaml.load(_unicode_open(StringIO(data.encode('utf-8')), 'utf-8')) assert output == value, (output, value) - for input in [data, data.encode('utf-8'), - codecs.BOM_UTF8 + data.encode('utf-8'), - codecs.BOM_UTF16_BE + data.encode('utf-16-be'), - codecs.BOM_UTF16_LE + data.encode('utf-16-le')]: + for input in [ + data, + data.encode('utf-8'), + codecs.BOM_UTF8 + data.encode('utf-8'), + codecs.BOM_UTF16_BE + data.encode('utf-16-be'), + codecs.BOM_UTF16_LE + data.encode('utf-16-le'), + ]: if verbose: - print("INPUT:", repr(input[:10]), "...") + print('INPUT:', repr(input[:10]), '...') output = yaml.load(input) assert output == value, (output, value) output = yaml.load(StringIO(input)) assert output == value, (output, value) + test_unicode_input.unittest = ['.unicode'] def test_unicode_input_errors(unicode_filename, verbose=False): with open(unicode_filename, 'rb') as fp: data = fp.read().decode('utf-8') - for input in [data.encode('latin1', 'ignore'), - data.encode('utf-16-be'), data.encode('utf-16-le'), - codecs.BOM_UTF8 + data.encode('utf-16-be'), - codecs.BOM_UTF16_BE + data.encode('utf-16-le'), - codecs.BOM_UTF16_LE + data.encode('utf-8') + b'!']: + for input in [ + data.encode('latin1', 'ignore'), + data.encode('utf-16-be'), + data.encode('utf-16-le'), + codecs.BOM_UTF8 + data.encode('utf-16-be'), + codecs.BOM_UTF16_BE + data.encode('utf-16-le'), + codecs.BOM_UTF16_LE + data.encode('utf-8') + b'!', + ]: try: yaml.load(input) except yaml.YAMLError as exc: if verbose: print(exc) else: - raise AssertionError("expected an exception") + raise AssertionError('expected an exception') try: yaml.load(BytesIO(input) if PY3 else StringIO(input)) except yaml.YAMLError as exc: if verbose: print(exc) else: - raise AssertionError("expected an exception") + raise AssertionError('expected an exception') test_unicode_input_errors.unittest = ['.unicode'] if PY3: + def test_unicode_output(unicode_filename, verbose=False): with open(unicode_filename, 'rb') as fp: data = fp.read().decode('utf-8') @@ -105,19 +121,20 @@ if PY3: stream = BytesIO() if encoding is None: try: - yaml.dump(value, stream, encoding=encoding, - allow_unicode=allow_unicode) + yaml.dump( + value, stream, encoding=encoding, allow_unicode=allow_unicode + ) except TypeError as exc: if verbose: print(exc) data4 = None else: - raise AssertionError("expected an exception") + raise AssertionError('expected an exception') else: yaml.dump(value, stream, encoding=encoding, allow_unicode=allow_unicode) data4 = stream.getvalue() if verbose: - print("BYTES:", data4[:50]) + print('BYTES:', data4[:50]) data4 = data4.decode(encoding) for copy in [data1, data2, data3, data4]: if copy is None: @@ -130,12 +147,15 @@ if PY3: if verbose: print(exc) else: - raise AssertionError("expected an exception") + raise AssertionError('expected an exception') else: copy[4:].encode('ascii') assert isinstance(data1, str), (type(data1), encoding) assert isinstance(data2, str), (type(data2), encoding) + + else: + def test_unicode_output(unicode_filename, verbose=False): with open(unicode_filename, 'rb') as fp: data = fp.read().decode('utf-8') @@ -144,8 +164,12 @@ else: data1 = yaml.dump(value, allow_unicode=allow_unicode) for encoding in [None, 'utf-8', 'utf-16-be', 'utf-16-le']: stream = StringIO() - yaml.dump(value, _unicode_open(stream, 'utf-8'), encoding=encoding, - allow_unicode=allow_unicode) + yaml.dump( + value, + _unicode_open(stream, 'utf-8'), + encoding=encoding, + allow_unicode=allow_unicode, + ) data2 = stream.getvalue() data3 = yaml.dump(value, encoding=encoding, allow_unicode=allow_unicode) stream = StringIO() @@ -159,7 +183,7 @@ else: if verbose: print(exc) else: - raise AssertionError("expected an exception") + raise AssertionError('expected an exception') else: copy[4:].encode('ascii') assert isinstance(data1, str), (type(data1), encoding) @@ -206,8 +230,7 @@ def test_file_output(unicode_filename, verbose=False): with open(filename, 'rb') as fp0: data2 = fp0.read() with open(filename, 'wb') as stream: - yaml.dump(data, stream, encoding='utf-16-le', - allow_unicode=True) + yaml.dump(data, stream, encoding='utf-16-le', allow_unicode=True) with open(filename, 'rb') as fp0: data3 = fp0.read().decode('utf-16-le')[1:].encode('utf-8') stream = _unicode_open(open(filename, 'wb'), 'utf-8') @@ -267,4 +290,5 @@ test_unicode_transfer.unittest = ['.unicode'] if __name__ == '__main__': import test_appliance + test_appliance.run(globals()) diff --git a/_test/lib/test_mark.py b/_test/lib/test_mark.py index 4e0728f..0ff2789 100644 --- a/_test/lib/test_mark.py +++ b/_test/lib/test_mark.py @@ -19,8 +19,7 @@ def test_marks(marks_filename, verbose=False): else: column += 1 index += 1 - mark = yaml.Mark(marks_filename, index, line, column, text_type(input), - index) + mark = yaml.Mark(marks_filename, index, line, column, text_type(input), index) snippet = mark.get_snippet(indent=2, max_length=79) if verbose: print(snippet) @@ -35,4 +34,5 @@ test_marks.unittest = ['.marks'] if __name__ == '__main__': import test_appliance + test_appliance.run(globals()) diff --git a/_test/lib/test_reader.py b/_test/lib/test_reader.py index 7ce0dc9..6604f24 100644 --- a/_test/lib/test_reader.py +++ b/_test/lib/test_reader.py @@ -1,7 +1,7 @@ from __future__ import absolute_import from __future__ import print_function -import codecs # NOQA +import codecs # NOQA import io from ruamel.yaml.compat import PY2 @@ -17,7 +17,7 @@ def _run_reader(data, verbose): if verbose: print(exc) else: - raise AssertionError("expected an exception") + raise AssertionError('expected an exception') def test_stream_error(error_filename, verbose=False): @@ -47,4 +47,5 @@ test_stream_error.unittest = ['.stream-error'] if __name__ == '__main__': import test_appliance + test_appliance.run(globals()) diff --git a/_test/lib/test_recursive.py b/_test/lib/test_recursive.py index e7084e7..c87f879 100644 --- a/_test/lib/test_recursive.py +++ b/_test/lib/test_recursive.py @@ -11,14 +11,12 @@ class AnInstance: def __repr__(self): try: - return "%s(foo=%r, bar=%r)" % (self.__class__.__name__, - self.foo, self.bar) + return '%s(foo=%r, bar=%r)' % (self.__class__.__name__, self.foo, self.bar) except RuntimeError: - return "%s(foo=..., bar=...)" % self.__class__.__name__ + return '%s(foo=..., bar=...)' % self.__class__.__name__ class AnInstanceWithState(AnInstance): - def __getstate__(self): return {'attributes': [self.foo, self.bar]} @@ -41,11 +39,11 @@ def test_recursive(recursive_filename, verbose=False): assert output1 == output2, (output1, output2) finally: if verbose: - print("VALUE1:", value1) - print("VALUE2:", value2) - print("OUTPUT1:") + print('VALUE1:', value1) + print('VALUE2:', value2) + print('OUTPUT1:') print(output1) - print("OUTPUT2:") + print('OUTPUT2:') print(output2) @@ -53,4 +51,5 @@ test_recursive.unittest = ['.recursive'] if __name__ == '__main__': import test_appliance + test_appliance.run(globals()) diff --git a/_test/lib/test_representer.py b/_test/lib/test_representer.py index 2c7e2c8..a83d2b2 100644 --- a/_test/lib/test_representer.py +++ b/_test/lib/test_representer.py @@ -14,8 +14,12 @@ def test_representer_types(code_filename, verbose=False): native1 = test_constructor._load_code(fp0.read()) native2 = None try: - output = yaml.dump(native1, Dumper=test_constructor.MyDumper, - allow_unicode=allow_unicode, encoding=encoding) + output = yaml.dump( + native1, + Dumper=test_constructor.MyDumper, + allow_unicode=allow_unicode, + encoding=encoding, + ) native2 = yaml.load(output, Loader=test_constructor.MyLoader) try: if native1 == native2: @@ -25,18 +29,18 @@ def test_representer_types(code_filename, verbose=False): value1 = test_constructor._serialize_value(native1) value2 = test_constructor._serialize_value(native2) if verbose: - print("SERIALIZED NATIVE1:") + print('SERIALIZED NATIVE1:') print(value1) - print("SERIALIZED NATIVE2:") + print('SERIALIZED NATIVE2:') print(value2) assert value1 == value2, (native1, native2) finally: if verbose: - print("NATIVE1:") + print('NATIVE1:') pprint.pprint(native1) - print("NATIVE2:") + print('NATIVE2:') pprint.pprint(native2) - print("OUTPUT:") + print('OUTPUT:') print(output) @@ -44,4 +48,5 @@ test_representer_types.unittest = ['.code'] if __name__ == '__main__': import test_appliance + test_appliance.run(globals()) diff --git a/_test/lib/test_resolver.py b/_test/lib/test_resolver.py index 4d1e6a4..0a04e7a 100644 --- a/_test/lib/test_resolver.py +++ b/_test/lib/test_resolver.py @@ -20,9 +20,9 @@ def test_implicit_resolver(data_filename, detect_filename, verbose=False): assert scalar.tag == correct_tag, (scalar.tag, correct_tag) finally: if verbose: - print("CORRECT TAG:", correct_tag) + print('CORRECT TAG:', correct_tag) if hasattr(node, 'value'): - print("CHILDREN:") + print('CHILDREN:') pprint.pprint(node.value) @@ -38,16 +38,19 @@ def _make_path_loader_and_dumper(): class MyDumper(yaml.Dumper): pass - yaml.add_path_resolver(u'!root', [], - Loader=MyLoader, Dumper=MyDumper) - yaml.add_path_resolver(u'!root/scalar', [], str, - Loader=MyLoader, Dumper=MyDumper) - yaml.add_path_resolver(u'!root/key11/key12/*', ['key11', 'key12'], - Loader=MyLoader, Dumper=MyDumper) - yaml.add_path_resolver(u'!root/key21/1/*', ['key21', 1], - Loader=MyLoader, Dumper=MyDumper) - yaml.add_path_resolver(u'!root/key31/*/*/key14/map', ['key31', None, None, 'key14'], dict, - Loader=MyLoader, Dumper=MyDumper) + yaml.add_path_resolver(u'!root', [], Loader=MyLoader, Dumper=MyDumper) + yaml.add_path_resolver(u'!root/scalar', [], str, Loader=MyLoader, Dumper=MyDumper) + yaml.add_path_resolver( + u'!root/key11/key12/*', ['key11', 'key12'], Loader=MyLoader, Dumper=MyDumper + ) + yaml.add_path_resolver(u'!root/key21/1/*', ['key21', 1], Loader=MyLoader, Dumper=MyDumper) + yaml.add_path_resolver( + u'!root/key31/*/*/key14/map', + ['key31', None, None, 'key14'], + dict, + Loader=MyLoader, + Dumper=MyDumper, + ) return MyLoader, MyDumper @@ -106,4 +109,5 @@ test_path_resolver_dumper.unittest = ['.data', '.path'] if __name__ == '__main__': import test_appliance + test_appliance.run(globals()) diff --git a/_test/lib/test_structure.py b/_test/lib/test_structure.py index 4d04b11..2656bbb 100644 --- a/_test/lib/test_structure.py +++ b/_test/lib/test_structure.py @@ -2,7 +2,7 @@ from __future__ import absolute_import from __future__ import print_function import ruamel.yaml as yaml -import canonical # NOQA +import canonical # NOQA import pprint from ruamel.yaml.compat import text_type, PY3 @@ -46,8 +46,12 @@ def test_structure(data_filename, structure_filename, verbose=False): with open(data_filename, 'rb') as fp: loader = yaml.Loader(fp) while loader.check_event(): - if loader.check_event(yaml.StreamStartEvent, yaml.StreamEndEvent, - yaml.DocumentStartEvent, yaml.DocumentEndEvent): + if loader.check_event( + yaml.StreamStartEvent, + yaml.StreamEndEvent, + yaml.DocumentStartEvent, + yaml.DocumentEndEvent, + ): loader.get_event() continue nodes1.append(_convert_structure(loader)) @@ -56,9 +60,9 @@ def test_structure(data_filename, structure_filename, verbose=False): assert nodes1 == nodes2, (nodes1, nodes2) finally: if verbose: - print("NODES1:") + print('NODES1:') pprint.pprint(nodes1) - print("NODES2:") + print('NODES2:') pprint.pprint(nodes2) @@ -89,9 +93,9 @@ def test_parser(data_filename, canonical_filename, verbose=False): _compare_events(events1, events2) finally: if verbose: - print("EVENTS1:") + print('EVENTS1:') pprint.pprint(events1) - print("EVENTS2:") + print('EVENTS2:') pprint.pprint(events2) @@ -109,9 +113,9 @@ def test_parser_on_canonical(canonical_filename, verbose=False): _compare_events(events1, events2, full=True) finally: if verbose: - print("EVENTS1:") + print('EVENTS1:') pprint.pprint(events1) - print("EVENTS2:") + print('EVENTS2:') pprint.pprint(events2) @@ -146,9 +150,9 @@ def test_composer(data_filename, canonical_filename, verbose=False): _compare_nodes(node1, node2) finally: if verbose: - print("NODES1:") + print('NODES1:') pprint.pprint(nodes1) - print("NODES2:") + print('NODES2:') pprint.pprint(nodes2) @@ -189,8 +193,9 @@ def _make_canonical_loader(): def construct_undefined(self, node): return self.construct_scalar(node) - MyCanonicalLoader.add_constructor(u'tag:yaml.org,2002:map', - MyCanonicalLoader.construct_mapping) + MyCanonicalLoader.add_constructor( + u'tag:yaml.org,2002:map', MyCanonicalLoader.construct_mapping + ) MyCanonicalLoader.add_constructor(None, MyCanonicalLoader.construct_undefined) @@ -207,9 +212,9 @@ def test_constructor(data_filename, canonical_filename, verbose=False): assert native1 == native2, (native1, native2) finally: if verbose: - print("NATIVE1:") + print('NATIVE1:') pprint.pprint(native1) - print("NATIVE2:") + print('NATIVE2:') pprint.pprint(native2) @@ -217,4 +222,5 @@ test_constructor.unittest = ['.data', '.canonical'] if __name__ == '__main__': import test_appliance + test_appliance.run(globals()) diff --git a/_test/lib/test_tokens.py b/_test/lib/test_tokens.py index e240efe..cdb41ba 100644 --- a/_test/lib/test_tokens.py +++ b/_test/lib/test_tokens.py @@ -53,13 +53,12 @@ def test_tokens(data_filename, tokens_filename, verbose=False): try: with open(data_filename, 'rb') as fp1: for token in yaml.scan(fp1): - if not isinstance( - token, (yaml.StreamStartToken, yaml.StreamEndToken)): + if not isinstance(token, (yaml.StreamStartToken, yaml.StreamEndToken)): tokens1.append(_replaces[token.__class__]) finally: if verbose: - print("TOKENS1:", ' '.join(tokens1)) - print("TOKENS2:", ' '.join(tokens2)) + print('TOKENS1:', ' '.join(tokens1)) + print('TOKENS2:', ' '.join(tokens2)) assert len(tokens1) == len(tokens2), (tokens1, tokens2) for token1, token2 in zip(tokens1, tokens2): assert token1 == token2, (token1, token2) @@ -84,4 +83,5 @@ test_scanner.unittest = ['.data', '.canonical'] if __name__ == '__main__': import test_appliance + test_appliance.run(globals()) diff --git a/_test/lib/test_yaml.py b/_test/lib/test_yaml.py index c650762..cf64a73 100644 --- a/_test/lib/test_yaml.py +++ b/_test/lib/test_yaml.py @@ -1,19 +1,20 @@ # coding: utf-8 -from test_mark import * # NOQA -from test_reader import * # NOQA -from test_canonical import * # NOQA -from test_tokens import * # NOQA -from test_structure import * # NOQA -from test_errors import * # NOQA -from test_resolver import * # NOQA -from test_constructor import * # NOQA -from test_emitter import * # NOQA -from test_representer import * # NOQA -from test_recursive import * # NOQA +from test_mark import * # NOQA +from test_reader import * # NOQA +from test_canonical import * # NOQA +from test_tokens import * # NOQA +from test_structure import * # NOQA +from test_errors import * # NOQA +from test_resolver import * # NOQA +from test_constructor import * # NOQA +from test_emitter import * # NOQA +from test_representer import * # NOQA +from test_recursive import * # NOQA from test_input_output import * # NOQA if __name__ == '__main__': import sys import test_appliance + sys.exit(test_appliance.run(globals())) diff --git a/_test/lib/test_yaml_ext.py b/_test/lib/test_yaml_ext.py index c4a1493..e36ddd0 100644 --- a/_test/lib/test_yaml_ext.py +++ b/_test/lib/test_yaml_ext.py @@ -173,8 +173,10 @@ def test_c_version(verbose=False): if verbose: print(_ruamel_yaml.get_version()) print(_ruamel_yaml.get_version_string()) - assert ("%s.%s.%s" % _ruamel_yaml.get_version()) == _ruamel_yaml.get_version_string(), \ - (_ruamel_yaml.get_version(), _ruamel_yaml.get_version_string()) + assert ('%s.%s.%s' % _ruamel_yaml.get_version()) == _ruamel_yaml.get_version_string(), ( + _ruamel_yaml.get_version(), + _ruamel_yaml.get_version_string(), + ) def _compare_scanners(py_data, c_data, verbose): @@ -190,20 +192,29 @@ def _compare_scanners(py_data, c_data, verbose): assert py_token.value == c_token.value, (py_token, c_token) if isinstance(py_token, ruamel.yaml.StreamEndToken): continue - py_start = (py_token.start_mark.index, py_token.start_mark.line, - py_token.start_mark.column) - py_end = (py_token.end_mark.index, py_token.end_mark.line, - py_token.end_mark.column) - c_start = (c_token.start_mark.index, c_token.start_mark.line, - c_token.start_mark.column) + py_start = ( + py_token.start_mark.index, + py_token.start_mark.line, + py_token.start_mark.column, + ) + py_end = ( + py_token.end_mark.index, + py_token.end_mark.line, + py_token.end_mark.column, + ) + c_start = ( + c_token.start_mark.index, + c_token.start_mark.line, + c_token.start_mark.column, + ) c_end = (c_token.end_mark.index, c_token.end_mark.line, c_token.end_mark.column) assert py_start == c_start, (py_start, c_start) assert py_end == c_end, (py_end, c_end) finally: if verbose: - print("PY_TOKENS:") + print('PY_TOKENS:') pprint.pprint(py_tokens) - print("C_TOKENS:") + print('C_TOKENS:') pprint.pprint(c_tokens) @@ -234,16 +245,24 @@ def _compare_parsers(py_data, c_data, verbose): c_events.append(event) assert len(py_events) == len(c_events), (len(py_events), len(c_events)) for py_event, c_event in zip(py_events, c_events): - for attribute in ['__class__', 'anchor', 'tag', 'implicit', - 'value', 'explicit', 'version', 'tags']: + for attribute in [ + '__class__', + 'anchor', + 'tag', + 'implicit', + 'value', + 'explicit', + 'version', + 'tags', + ]: py_value = getattr(py_event, attribute, None) c_value = getattr(c_event, attribute, None) assert py_value == c_value, (py_event, c_event, attribute) finally: if verbose: - print("PY_EVENTS:") + print('PY_EVENTS:') pprint.pprint(py_events) - print("C_EVENTS:") + print('C_EVENTS:') pprint.pprint(c_events) @@ -277,13 +296,25 @@ def _compare_emitters(data, verbose): assert len(events) == len(py_events), (len(events), len(py_events)) assert len(events) == len(c_events), (len(events), len(c_events)) for event, py_event, c_event in zip(events, py_events, c_events): - for attribute in ['__class__', 'anchor', 'tag', 'implicit', - 'value', 'explicit', 'version', 'tags']: + for attribute in [ + '__class__', + 'anchor', + 'tag', + 'implicit', + 'value', + 'explicit', + 'version', + 'tags', + ]: value = getattr(event, attribute, None) py_value = getattr(py_event, attribute, None) c_value = getattr(c_event, attribute, None) - if attribute == 'tag' and value in [None, u'!'] \ - and py_value in [None, u'!'] and c_value in [None, u'!']: + if ( + attribute == 'tag' + and value in [None, u'!'] + and py_value in [None, u'!'] + and c_value in [None, u'!'] + ): continue if attribute == 'explicit' and (py_value or c_value): continue @@ -291,11 +322,11 @@ def _compare_emitters(data, verbose): assert value == c_value, (event, c_event, attribute) finally: if verbose: - print("EVENTS:") + print('EVENTS:') pprint.pprint(events) - print("PY_EVENTS:") + print('PY_EVENTS:') pprint.pprint(py_events) - print("C_EVENTS:") + print('C_EVENTS:') pprint.pprint(c_events) @@ -317,6 +348,7 @@ def wrap_ext_function(function): function(*args, **kwds) finally: _tear_down() + if PY3: wrapper.__name__ = '%s_ext' % function.__name__ else: @@ -349,19 +381,33 @@ def wrap_ext(collections): assert function.unittest_name not in globals() globals()[function.unittest_name] = function -import test_tokens # NOQA -import test_structure # NOQA -import test_errors # NOQA -import test_resolver # NOQA -import test_constructor # NOQA -import test_emitter # NOQA -import test_representer # NOQA -import test_recursive # NOQA -import test_input_output # NOQA -wrap_ext([test_tokens, test_structure, test_errors, test_resolver, test_constructor, - test_emitter, test_representer, test_recursive, test_input_output]) + +import test_tokens # NOQA +import test_structure # NOQA +import test_errors # NOQA +import test_resolver # NOQA +import test_constructor # NOQA +import test_emitter # NOQA +import test_representer # NOQA +import test_recursive # NOQA +import test_input_output # NOQA + +wrap_ext( + [ + test_tokens, + test_structure, + test_errors, + test_resolver, + test_constructor, + test_emitter, + test_representer, + test_recursive, + test_input_output, + ] +) if __name__ == '__main__': import sys import test_appliance + sys.exit(test_appliance.run(globals())) -- cgit v1.2.1