Skip to content

Commit

Permalink
test: refactor (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored May 20, 2024
1 parent e7321e5 commit b15d1be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def test_get_imports_cache_folder(project, compiler):

# Reset because this config is stateful across tests
compile_config.cache_folder = og_cache_colder
shutil.rmtree(og_cache_colder)
shutil.rmtree(og_cache_colder, ignore_errors=True)


def test_get_imports_raises_when_non_solidity_files(compiler, vyper_source_path):
Expand Down Expand Up @@ -265,8 +265,7 @@ def test_get_version_map(project, compiler):
# Files are selected in order to trigger `CompilesOnce.sol` to
# get removed from version '0.8.12'.
cache_folder = project.contracts_folder / ".cache"
if cache_folder.is_dir():
shutil.rmtree(cache_folder)
shutil.rmtree(cache_folder, ignore_errors=True)

file_paths = [
project.contracts_folder / "ImportSourceWithEqualSignVersion.sol",
Expand Down Expand Up @@ -369,7 +368,7 @@ def run_test(manifest):

# Ensure compiled first so that the local cached manifest exists.
# We want to make ape-solidity has placed the compiler info in there.
project.load_contracts()
project.load_contracts(use_cache=False)
if man := project.local_project.manifest:
run_test(man)
else:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def runner():


def test_compile_using_cli(ape_cli, runner):
result = runner.invoke(ape_cli, ["compile"], catch_exceptions=False)
result = runner.invoke(ape_cli, ("compile", "--force"), catch_exceptions=False)
assert result.exit_code == 0
assert "CompilesOnce" in result.output
result = runner.invoke(ape_cli, ["compile"], catch_exceptions=False)
result = runner.invoke(ape_cli, "compile", catch_exceptions=False)

# Already compiled so does not compile again.
assert "CompilesOnce" not in result.output
Expand All @@ -33,11 +33,11 @@ def test_compile_using_cli(ape_cli, runner):
),
)
def test_compile_specified_contracts(ape_cli, runner, contract_path):
result = runner.invoke(ape_cli, ["compile", contract_path, "--force"], catch_exceptions=False)
result = runner.invoke(ape_cli, ("compile", contract_path, "--force"), catch_exceptions=False)
assert result.exit_code == 0, result.output
assert "Compiling 'CompilesOnce.sol'" in result.output, f"Failed to compile {contract_path}."


def test_force_recompile(ape_cli, runner):
result = runner.invoke(ape_cli, ["compile", "--force"], catch_exceptions=False)
result = runner.invoke(ape_cli, ("compile", "--force"), catch_exceptions=False)
assert result.exit_code == 0

0 comments on commit b15d1be

Please sign in to comment.