diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-09-02 09:43:41 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-09-02 12:16:45 +0200 |
| commit | 065766883f5e34d20ca88084cd747813a84ed2d3 (patch) | |
| tree | 2bca2c34d113f0198564155ac21789466d4b8b96 /tools/qtpy2cpp_lib/tests/test_qtpy2cpp.py | |
| parent | 4cfa700d5965922b5156517a64790369deac354f (diff) | |
Move qtpy2cpp to sources/pyside-tools
Preparing the entry point.
Task-number: PYSIDE-1945
Change-Id: I4a2fbe6d35b4f97bf0ab7cfc2085b86a40bc2558
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'tools/qtpy2cpp_lib/tests/test_qtpy2cpp.py')
| -rw-r--r-- | tools/qtpy2cpp_lib/tests/test_qtpy2cpp.py | 54 |
1 files changed, 0 insertions, 54 deletions
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) |
