diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/tools/cython/Cython/TestUtils.py | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/cython/Cython/TestUtils.py')
-rw-r--r-- | contrib/tools/cython/Cython/TestUtils.py | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/contrib/tools/cython/Cython/TestUtils.py b/contrib/tools/cython/Cython/TestUtils.py index 9d6eb67fc3..847647b157 100644 --- a/contrib/tools/cython/Cython/TestUtils.py +++ b/contrib/tools/cython/Cython/TestUtils.py @@ -1,16 +1,16 @@ -from __future__ import absolute_import +from __future__ import absolute_import -import os +import os import unittest import tempfile -from .Compiler import Errors -from .CodeWriter import CodeWriter -from .Compiler.TreeFragment import TreeFragment, strip_common_indent -from .Compiler.Visitor import TreeVisitor, VisitorTransform -from .Compiler import TreePath - +from .Compiler import Errors +from .CodeWriter import CodeWriter +from .Compiler.TreeFragment import TreeFragment, strip_common_indent +from .Compiler.Visitor import TreeVisitor, VisitorTransform +from .Compiler import TreePath + class NodeTypeWriter(TreeVisitor): def __init__(self): super(NodeTypeWriter, self).__init__() @@ -57,15 +57,15 @@ class CythonTest(unittest.TestCase): def assertLines(self, expected, result): "Checks that the given strings or lists of strings are equal line by line" - if not isinstance(expected, list): - expected = expected.split(u"\n") - if not isinstance(result, list): - result = result.split(u"\n") + if not isinstance(expected, list): + expected = expected.split(u"\n") + if not isinstance(result, list): + result = result.split(u"\n") for idx, (expected_line, result_line) in enumerate(zip(expected, result)): - self.assertEqual(expected_line, result_line, - "Line %d:\nExp: %s\nGot: %s" % (idx, expected_line, result_line)) + self.assertEqual(expected_line, result_line, + "Line %d:\nExp: %s\nGot: %s" % (idx, expected_line, result_line)) self.assertEqual(len(expected), len(result), - "Unmatched lines. Got:\n%s\nExpected:\n%s" % ("\n".join(expected), u"\n".join(result))) + "Unmatched lines. Got:\n%s\nExpected:\n%s" % ("\n".join(expected), u"\n".join(result))) def codeToLines(self, tree): writer = CodeWriter() @@ -81,24 +81,24 @@ class CythonTest(unittest.TestCase): expected_lines = strip_common_indent(expected.split("\n")) for idx, (line, expected_line) in enumerate(zip(result_lines, expected_lines)): - self.assertEqual(expected_line, line, - "Line %d:\nGot: %s\nExp: %s" % (idx, line, expected_line)) + self.assertEqual(expected_line, line, + "Line %d:\nGot: %s\nExp: %s" % (idx, line, expected_line)) self.assertEqual(len(result_lines), len(expected_lines), - "Unmatched lines. Got:\n%s\nExpected:\n%s" % ("\n".join(result_lines), expected)) + "Unmatched lines. Got:\n%s\nExpected:\n%s" % ("\n".join(result_lines), expected)) def assertNodeExists(self, path, result_tree): self.assertNotEqual(TreePath.find_first(result_tree, path), None, "Path '%s' not found in result tree" % path) - def fragment(self, code, pxds=None, pipeline=None): + def fragment(self, code, pxds=None, pipeline=None): "Simply create a tree fragment using the name of the test-case in parse errors." - if pxds is None: - pxds = {} - if pipeline is None: - pipeline = [] + if pxds is None: + pxds = {} + if pipeline is None: + pipeline = [] name = self.id() - if name.startswith("__main__."): - name = name[len("__main__."):] + if name.startswith("__main__."): + name = name[len("__main__."):] name = name.replace(".", "_") return TreeFragment(code, name, pxds, pipeline=pipeline) @@ -112,8 +112,8 @@ class CythonTest(unittest.TestCase): try: func() self.fail("Expected an exception of type %r" % exc_type) - except exc_type as e: - self.assertTrue(isinstance(e, exc_type)) + except exc_type as e: + self.assertTrue(isinstance(e, exc_type)) return e def should_not_fail(self, func): @@ -122,8 +122,8 @@ class CythonTest(unittest.TestCase): the return value of func.""" try: return func() - except Exception as exc: - self.fail(str(exc)) + except Exception as exc: + self.fail(str(exc)) class TransformTest(CythonTest): @@ -150,9 +150,9 @@ class TransformTest(CythonTest): Plans: One could have a pxd dictionary parameter to run_pipeline. """ - def run_pipeline(self, pipeline, pyx, pxds=None): - if pxds is None: - pxds = {} + def run_pipeline(self, pipeline, pyx, pxds=None): + if pxds is None: + pxds = {} tree = self.fragment(pyx, pxds).root # Run pipeline for T in pipeline: |