Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix issue with ape test tests when vyper / solidity installed #2226

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions tests/integration/cli/test_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
Loading