From 065766883f5e34d20ca88084cd747813a84ed2d3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 2 Sep 2022 09:43:41 +0200 Subject: Move qtpy2cpp to sources/pyside-tools Preparing the entry point. Task-number: PYSIDE-1945 Change-Id: I4a2fbe6d35b4f97bf0ab7cfc2085b86a40bc2558 Reviewed-by: Christian Tismer --- tools/qtpy2cpp_lib/tests/test_qtpy2cpp.py | 54 ------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 tools/qtpy2cpp_lib/tests/test_qtpy2cpp.py (limited to 'tools/qtpy2cpp_lib/tests/test_qtpy2cpp.py') diff --git a/tools/qtpy2cpp_lib/tests/test_qtpy2cpp.py b/tools/qtpy2cpp_lib/tests/test_qtpy2cpp.py deleted file mode 100644 index f9f921705..000000000 --- a/tools/qtpy2cpp_lib/tests/test_qtpy2cpp.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -import subprocess -import tempfile -import sys -from pathlib import Path - -# run pytest-3 - - -def diff_code(actual_code, expected_file): - """Helper to run diff if something fails (Linux only).""" - with tempfile.NamedTemporaryFile(suffix=".cpp") as tf: - tf.write(actual_code.encode('utf-8')) - tf.flush() - diff_cmd = ["diff", "-u", expected_file, tf.name] - subprocess.run(diff_cmd) - - -def run_converter(tool, file): - """Run the converter and return C++ code generated from file.""" - cmd = [sys.executable, tool, "--stdout", file] - output = "" - with subprocess.Popen(cmd, stdout=subprocess.PIPE) as proc: - output_b, errors_b = proc.communicate() - output = output_b.decode('utf-8') - if errors_b: - print(errors_b.decode('utf-8'), file=sys.stderr) - return output - - -def test_examples(): - dir = Path(__file__).resolve().parent - tool = dir.parents[1] / "qtpy2cpp.py" - assert(tool.is_file) - for test_file in (dir / "baseline").glob("*.py"): - assert(test_file.is_file) - expected_file = test_file.parent / (test_file.stem + ".cpp") - if expected_file.is_file(): - actual_code = run_converter(tool, test_file) - assert(actual_code) - expected_code = expected_file.read_text() - # Strip the license - code_start = expected_code.find("// Converted from") - assert(code_start != -1) - expected_code = expected_code[code_start:] - - if actual_code != expected_code: - diff_code(actual_code, expected_file) - assert(actual_code == expected_code) - else: - print(f"Warning, {test_file} is missing a .cpp file.", - file=sys.stderr) -- cgit v1.2.3