From 2ce996c688e7ca20feb842d898ca38a98af51e1a Mon Sep 17 00:00:00 2001 From: sulyi Date: Mon, 4 Jun 2018 04:25:06 +0200 Subject: [PATCH] [jsinterp] Unicode docstring hack --- test/js2tests/__init__.py | 91 ++++++++++++++++++------------------ test/test_jsinterp.py | 7 ++- test/test_jsinterp2.py | 7 ++- test/test_jsinterp2_parse.py | 7 ++- 4 files changed, 55 insertions(+), 57 deletions(-) diff --git a/test/js2tests/__init__.py b/test/js2tests/__init__.py index 05df89c4f..0dd8139aa 100644 --- a/test/js2tests/__init__.py +++ b/test/js2tests/__init__.py @@ -1,53 +1,54 @@ # TODO use json instead of py # TODO create devscript to generate ASTs (using e.g. acorn) -# """ -# This package contains templates for `test_jsinterp` and `test_interp_parse` to create test methods. -# These modules will create a test method for each module in this package. A test method consist of one or more subtest. -# Each subtest initializes an instance of the tested class and runs one or more assertion. -# -# Any module should have a `list` of `dict` named ``tests`` and optionally a `dict` named ``skip``. -# -# Each `dict` in ``tests`` may have the following keys: -# -# code: If missing subtest is skipped, Otherwise it's value is used as code to initialize the tested class. -# globals: Optional. Used only by `test_jsinterp`. If set used as argument `variables` initializing `JSInterperter`. -# asserts: Used only by `test_jsinterp`. If this is missing subtest is skipped, Should be a list of `dict`, each -# used as an assertion for the initialized `JSInterpreter`. Each `dict` may have the following keys: -# value: If missing assertion is skipped. Otherwise it's value is used as expected value in -# an `assertEqual` call. -# call: Optional. If set used as arguments of a `call_function` call of the initialized `JSInterpreter` -# and the actual value of the created `assertEqual` call will be the return value of it. -# Otherwise the actual value will be the return value of the `run` call. -# ast: Used only by `test_interp_parse`. If missing subtest is skipped, Otherwise it's value is used as -# expected value in an `assertEqual` call. The actual value will be the return value of the `parse` call -# converted to `list`. Both on expected anc actual value `traverse` is called first to flatten and handle `zip` -# objects. -# -# In the `dict` named ``skip`` is optional and may have the following keys: -# interpret -# parse -# Both used as the argument of `skipTest` decorator of the created test method in `test_jsinterp` -# and `test_jsinterp_parse` respectably. Unless they're value is `True`, that case the test method is skipped entirely, -# or `False`, which is the default value. -# -# Example: -# This is not a functional template, rather a skeleton: -# -# skip = {'interpret': 'Test not yet implemented', -# 'parse': 'Test not yet implemented'} -# -# tests = [ -# { -# 'code': '', -# 'globals': {}, -# 'asserts': [{'value': 0, 'call': ('f',)}], -# 'ast': [] -# } -# ] -# """ from __future__ import unicode_literals +__doc__ = """ +This package contains templates for `test_jsinterp` and `test_interp_parse` to create test methods. +These modules will create a test method for each module in this package. A test method consist of one or more subtest. +Each subtest initializes an instance of the tested class and runs one or more assertion. + +Any module should have a `list` of `dict` named ``tests`` and optionally a `dict` named ``skip``. + +Each `dict` in ``tests`` may have the following keys: + + code: If missing subtest is skipped, Otherwise it's value is used as code to initialize the tested class. + globals: Optional. Used only by `test_jsinterp`. If set used as argument `variables` initializing `JSInterperter`. + asserts: Used only by `test_jsinterp`. If this is missing subtest is skipped, Should be a list of `dict`, each + used as an assertion for the initialized `JSInterpreter`. Each `dict` may have the following keys: + value: If missing assertion is skipped. Otherwise it's value is used as expected value in + an `assertEqual` call. + call: Optional. If set used as arguments of a `call_function` call of the initialized `JSInterpreter` + and the actual value of the created `assertEqual` call will be the return value of it. + Otherwise the actual value will be the return value of the `run` call. + ast: Used only by `test_interp_parse`. If missing subtest is skipped, Otherwise it's value is used as + expected value in an `assertEqual` call. The actual value will be the return value of the `parse` call + converted to `list`. Both on expected anc actual value `traverse` is called first to flatten and handle `zip` + objects. + +In the `dict` named ``skip`` is optional and may have the following keys: + interpret + parse +Both used as the argument of `skipTest` decorator of the created test method in `test_jsinterp` +and `test_jsinterp_parse` respectably. Unless they're value is `True`, that case the test method is skipped entirely, +or `False`, which is the default value. + +Example: + This is not a functional template, rather a skeleton: + + skip = {'interpret': 'Test not yet implemented', + 'parse': 'Test not yet implemented'} + + tests = [ + { + 'code': '', + 'globals': {}, + 'asserts': [{'value': 0, 'call': ('f',)}], + 'ast': [] + } + ] +""" + def gettestcases(): import os diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py index 282c4a90c..78cf9fb61 100644 --- a/test/test_jsinterp.py +++ b/test/test_jsinterp.py @@ -1,9 +1,5 @@ #!/usr/bin/env python -# """ -# see: `js2tests` -# """ - from __future__ import unicode_literals # Allow direct execution @@ -20,6 +16,9 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from youtube_dl.jsinterp import JSInterpreter from .js2tests import gettestcases +__doc__ = """see: `js2tests`""" + + defs = gettestcases() # set level to logging.DEBUG to see messages about missing assertions logging.basicConfig(stream=sys.stderr, level=logging.WARNING) diff --git a/test/test_jsinterp2.py b/test/test_jsinterp2.py index 3a2b9d35f..63b237e2c 100644 --- a/test/test_jsinterp2.py +++ b/test/test_jsinterp2.py @@ -1,9 +1,5 @@ #!/usr/bin/env python -# """ -# see: `js2tests` -# """ - from __future__ import unicode_literals # Allow direct execution @@ -20,6 +16,9 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from youtube_dl.jsinterp2 import JSInterpreter from .js2tests import gettestcases +__doc__ = """see: `js2tests`""" + + defs = gettestcases() # set level to logging.DEBUG to see messages about missing assertions logging.basicConfig(stream=sys.stderr, level=logging.WARNING) diff --git a/test/test_jsinterp2_parse.py b/test/test_jsinterp2_parse.py index 4fee2cbc6..e2b6c8b7a 100644 --- a/test/test_jsinterp2_parse.py +++ b/test/test_jsinterp2_parse.py @@ -1,9 +1,5 @@ #!/usr/bin/env python -# """ -# see: `js2tests` -# """ - from __future__ import unicode_literals # Allow direct execution @@ -34,6 +30,9 @@ def traverse(node, tree_types=(list, tuple)): return node +__doc__ = """see: `js2tests`""" + + defs = gettestcases() # set level to logging.DEBUG to see messages about not set ASTs logging.basicConfig(stream=sys.stderr, level=logging.WARNING)