File tree Expand file tree Collapse file tree 5 files changed +41
-2
lines changed Expand file tree Collapse file tree 5 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -49,3 +49,6 @@ docs/_build
4949
5050# Known Contracts
5151** /known_contracts.json
52+
53+ # py.test cache
54+ .cache
Original file line number Diff line number Diff line change 55[ ![ PyPi downloads] ( https://pypip.in/d/py-solc/badge.png )] ( https://pypi.python.org/pypi/py-solc )
66
77
8- Python wrapper around the ` solc ` solidity compiler.
8+ Python wrapper around the ` solc ` Solidity compiler.
99
1010
1111# Dependency
1212
1313This library requires the ` solc ` executable to be present.
1414
15+ solc 0.3.5 or newer is required. [ solc installation instructions] ( http://solidity.readthedocs.io/en/latest/installing-solidity.html )
16+
1517
1618# Quickstart
1719
Original file line number Diff line number Diff line change @@ -4,3 +4,7 @@ class SolcError(Exception):
44
55class CompileError (Exception ):
66 pass
7+
8+
9+ class ContractsNotFound (Exception ):
10+ """No contracts was found in the target folder."""
Original file line number Diff line number Diff line change 66
77from .exceptions import (
88 SolcError ,
9+ ContractsNotFound ,
910)
1011
1112from .utils .formatting import (
@@ -39,7 +40,15 @@ def get_solc_version():
3940
4041
4142def _parse_compiler_output (stdoutdata ):
42- contracts = json .loads (stdoutdata )['contracts' ]
43+
44+ output = json .loads (stdoutdata )
45+
46+ if "contracts" not in output :
47+ # {'sources': {}, 'version': 'xxx'}
48+ # solc did not pick up any contracts
49+ raise ContractsNotFound (output )
50+
51+ contracts = output ['contracts' ]
4352
4453 for _ , data in contracts .items ():
4554 data ['abi' ] = json .loads (data ['abi' ])
Original file line number Diff line number Diff line change 1+ import os
2+ import tempfile
3+
4+ import pytest
5+
6+ from solc import (
7+ compile_files ,
8+ )
9+
10+ from solc .exceptions import ContractsNotFound
11+
12+
13+ def test_compile_empty_folder ():
14+ """Execute compile on a folder without contracts."""
15+
16+ tmpdirname = tempfile .mkdtemp ()
17+ try :
18+ with pytest .raises (ContractsNotFound ):
19+ compile_files (tmpdirname )
20+ finally :
21+ os .rmdir (tmpdirname )
You can’t perform that action at this time.
0 commit comments