From b15d1bebfcc4efb6477feb2ea3312a0a6a83913a Mon Sep 17 00:00:00 2001 From: antazoey Date: Mon, 20 May 2024 09:55:07 -0500 Subject: [PATCH] test: refactor (#143) --- tests/test_compiler.py | 7 +++---- tests/test_integration.py | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/test_compiler.py b/tests/test_compiler.py index 7c10d4b..0a7bc3d 100644 --- a/tests/test_compiler.py +++ b/tests/test_compiler.py @@ -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): @@ -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", @@ -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: diff --git a/tests/test_integration.py b/tests/test_integration.py index e36c95e..f099339 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -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 @@ -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