From 21a66d0e862ce160abe0a3b9849181a2e0e3f2d0 Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Tue, 20 Aug 2024 18:17:36 -0500 Subject: [PATCH] test: fix issue with test tests --- tests/integration/cli/test_test.py | 34 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/integration/cli/test_test.py b/tests/integration/cli/test_test.py index 7c40f99707..735717bd7f 100644 --- a/tests/integration/cli/test_test.py +++ b/tests/integration/cli/test_test.py @@ -89,19 +89,21 @@ def setup(project): test_files = {} if tests_path.is_dir(): for file_path in tests_path.iterdir(): - if file_path.name.startswith("test_") and file_path.suffix == ".py": - content = file_path.read_text() - test_files[file_path.name] = content - num_passes += len( - [ - x - for x in content.splitlines() - if x.startswith("def test_") and not x.startswith("def test_fail_") - ] - ) - num_failed += len( - [x for x in content.splitlines() if x.startswith("def test_fail_")] - ) + if not file_path.name.startswith("test_") or file_path.suffix != ".py": + continue + + content = file_path.read_text(encoding="utf8") + test_files[file_path.name] = content + num_passes += len( + [ + x + for x in content.splitlines() + if x.startswith("def test_") and not x.startswith("def test_fail_") + ] + ) + num_failed += len( + [x for x in content.splitlines() if x.startswith("def test_fail_")] + ) pytester.makepyfile(**test_files) @@ -111,16 +113,16 @@ def _make_all_files(base: Path, prefix: Optional[Path] = None): return for file in base.iterdir(): - if file.is_dir() and not file.name == "tests": + if file.is_dir() and file.name != "tests": _make_all_files(file, prefix=Path(file.name)) - elif file.is_file(): + elif file.is_file() and file.suffix not in (".sol", ".vy"): name = (prefix / file.name).as_posix() if prefix else file.name if name == "ape-config.yaml": # Hack in in-memory overrides for testing purposes. text = str(project.config) else: - text = file.read_text() + text = file.read_text(encoding="utf8") src = {name: text.splitlines()} pytester.makefile(file.suffix, **src)