Пример #1
0
def main():
    python_version = setup(suite="basics", needs_io_encoding=True)

    search_mode = createSearchMode()

    # Singleton, pylint: disable=global-statement
    global operations
    global candidates

    if python_version >= (3, 5):
        operations += (("MatMult", "@"),)

    if python_version < (3,):
        candidates += (("long", "17L", "-9L"),)
        candidates += (("unicode", "u'lala'", "u'lele'"),)
    else:
        candidates += (("bytes", "b'lala'", "b'lele'"),)

    template_context = {
        "operations": operations,
        "ioperations": tuple(
            operation
            for operation in operations
            if operation[0] not in ("Divmod", "Subscript")
        ),
        "candidates": candidates,
        "makeOperatorUsage": makeOperatorUsage,
    }

    # Now run all the tests in this directory.
    for filename in scanDirectoryForTestCases(".", template_context=template_context):
        extra_flags = [
            # No error exits normally, unless we break tests, and that we would
            # like to know.
            "expect_success",
            # Keep no temporary files.
            "remove_output",
            # Include imported files, mostly nothing though.
            "recurse_all",
            # Use the original __file__ value, at least one case warns about things
            # with filename included.
            "original_file",
            # Cache the CPython results for re-use, they will normally not change.
            "cpython_cache",
            # We annotate some tests, use that to lower warnings.
            "plugin_enable:pylint-warnings",
        ]

        # This test should be run with the debug Python, and makes outputs to

        active = search_mode.consider(dirname=None, filename=filename)

        if active:
            compareWithCPython(
                dirname=None,
                filename=filename,
                extra_flags=extra_flags,
                search_mode=search_mode,
                needs_2to3=decideNeeds2to3(filename),
            )

    search_mode.finish()
def main():
    setup(suite="basics", needs_io_encoding=True)

    search_mode = createSearchMode()

    # Now run all the tests in this directory.
    for filename in scanDirectoryForTestCases("."):
        extra_flags = [
            # No error exits normally, unless we break tests, and that we would
            # like to know.
            "expect_success",
            # Keep no temporary files.
            "remove_output",
            # Include imported files, mostly nothing though.
            "recurse_all",
            # Use the original __file__ value, at least one case warns about things
            # with filename included.
            "original_file",
            # Cache the CPython results for re-use, they will normally not change.
            "cpython_cache",
            # To understand what is slow.
            "timing",
            # We annotate some tests, use that to lower warnings.
            "plugin_enable:pylint-warnings",
        ]

        # This test should be run with the debug Python, and makes outputs to
        # standard error that might be ignored.
        if filename.startswith("Referencing"):
            extra_flags.append("recurse_not:nuitka")

            if hasDebugPython():
                extra_flags.append("python_debug")

        # This tests warns about __import__() used.
        if filename == "OrderChecks.py":
            extra_flags.append("ignore_warnings")

        # This tests warns about an package relative import despite
        # being in no package.
        if filename == "Importing.py":
            extra_flags.append("ignore_warnings")

        # TODO: Nuitka does not give output for ignored exception in dtor, this is
        # not fully compatible and potentially an error.
        if filename == "YieldFrom33.py":
            extra_flags.append("ignore_stderr")

        # For Python2 there is a "builtins" package that gives warnings. TODO: We
        # ought to NOT import that package and detect statically that __builtins__
        # import won't raise ImportError.
        if filename == "BuiltinOverload.py":
            extra_flags.append("ignore_warnings")

        active = search_mode.consider(dirname=None, filename=filename)

        if active:
            compareWithCPython(
                dirname=None,
                filename=filename,
                extra_flags=extra_flags,
                search_mode=search_mode,
                needs_2to3=decideNeeds2to3(filename),
            )

            if search_mode.abortIfExecuted():
                break

    search_mode.finish()