-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from iamdefinitelyahuman/v0.4.3
V0.5.0
- Loading branch information
Showing
9 changed files
with
168 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/python3 | ||
|
||
import pytest | ||
import sys | ||
|
||
import solcx | ||
from solcx.exceptions import SolcNotInstalled | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def isolation(): | ||
p = sys.platform | ||
v = solcx.install.solc_version | ||
yield | ||
sys.platform = p | ||
solcx.install.solc_version = v | ||
|
||
|
||
def test_not_installed(): | ||
solcx.install.get_executable() | ||
with pytest.raises(SolcNotInstalled): | ||
solcx.install.get_executable('v0.4.0') | ||
solcx.install.solc_version = None | ||
with pytest.raises(SolcNotInstalled): | ||
solcx.install.get_executable() | ||
|
||
|
||
def test_unsupported_version(): | ||
solcx.install._check_version('0.4.11') | ||
with pytest.raises(ValueError): | ||
solcx.install._check_version('0.4.10') | ||
|
||
|
||
def test_unknown_platform(): | ||
sys.platform = "potatoOS" | ||
with pytest.raises(KeyError): | ||
solcx.install_solc('0.5.0') | ||
|
||
|
||
@pytest.mark.skipif("sys.platform == 'win32'") | ||
def test_install_osx(): | ||
sys.platform = "darwin" | ||
with pytest.raises(ValueError): | ||
solcx.install_solc('0.4.25') | ||
solcx.install_solc('0.4.25', allow_osx=True) | ||
solcx.install_solc('0.5.4') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/python3 | ||
|
||
import subprocess | ||
import pytest | ||
|
||
import solcx | ||
|
||
|
||
class PopenPatch: | ||
|
||
def __init__(self): | ||
self.proc = subprocess.Popen | ||
self.args = [] | ||
|
||
def __call__(self, cmd, **kwargs): | ||
assert cmd[0] == solcx.install.get_executable() | ||
for i in self.args: | ||
assert i in cmd | ||
return self.proc(cmd, **kwargs) | ||
|
||
def expect(self, *args): | ||
self.args = [f"--{i.replace('_', '-')}" for i in args] | ||
|
||
|
||
@pytest.fixture | ||
def popen(monkeypatch): | ||
p = PopenPatch() | ||
monkeypatch.setattr('subprocess.Popen', p) | ||
yield p | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def all_(all_versions): | ||
pass | ||
|
||
|
||
def test_help(popen): | ||
popen.expect('help') | ||
solcx.wrapper.solc_wrapper(help=True, success_return_code=1) | ||
|
||
|
||
def test_boolean_kwargs(popen, foo_source): | ||
kwargs = [ | ||
'version', 'optimize', 'gas', 'ast', 'ast_json', 'asm', 'asm_json', | ||
'opcodes', 'bin', 'bin_runtime', 'abi', 'hashes', 'userdoc', 'devdoc', 'standard_json' | ||
] | ||
for value in kwargs: | ||
popen.expect(value) | ||
solcx.wrapper.solc_wrapper(stdin=foo_source, **{value: True}) | ||
|
||
|
||
def test_solc4_only_kwargs(popen): | ||
kwargs = ['clone_bin', 'formal'] | ||
if "0.5" in solcx.get_solc_version_string(): | ||
for value in kwargs: | ||
popen.expect(value) | ||
with pytest.raises(AttributeError): | ||
solcx.wrapper.solc_wrapper(**{value: True}) | ||
return | ||
for value in kwargs: | ||
popen.expect(value) | ||
solcx.wrapper.solc_wrapper(**{value: True}) | ||
|
||
|
||
def test_value_kwargs(popen, foo_source): | ||
kwargs = [ | ||
('optimize_runs', 200), | ||
('libraries', "libraries:0x1234567890123456789012345678901234567890"), | ||
('output_dir', "."), | ||
('combined_json', "abi"), | ||
('allow_paths', ".") | ||
] | ||
for value in kwargs: | ||
popen.expect(value[0]) | ||
solcx.wrapper.solc_wrapper(stdin=foo_source, **{value[0]: value[1]}) |