File tree 5 files changed +37
-2
lines changed
5 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -49,3 +49,6 @@ docs/_build
49
49
50
50
# Known Contracts
51
51
** /known_contracts.json
52
+
53
+ # py.test cache
54
+ .cache
Original file line number Diff line number Diff line change 5
5
[ ![ PyPi downloads] ( https://pypip.in/d/py-solc/badge.png )] ( https://pypi.python.org/pypi/py-solc )
6
6
7
7
8
- Python wrapper around the ` solc ` solidity compiler.
8
+ Python wrapper around the ` solc ` Solidity compiler.
9
9
10
10
11
11
# Dependency
12
12
13
13
This library requires the ` solc ` executable to be present.
14
14
15
+ solc 0.3.5 or newer is required. [ solc installation instructions] ( http://solidity.readthedocs.io/en/latest/installing-solidity.html )
16
+
15
17
16
18
# Quickstart
17
19
Original file line number Diff line number Diff line change @@ -4,3 +4,7 @@ class SolcError(Exception):
4
4
5
5
class CompileError (Exception ):
6
6
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 6
6
7
7
from .exceptions import (
8
8
SolcError ,
9
+ ContractsNotFound ,
9
10
)
10
11
11
12
from .utils .formatting import (
@@ -39,7 +40,15 @@ def get_solc_version():
39
40
40
41
41
42
def _parse_compiler_output (stdoutdata ):
42
- contracts = json .loads (stdoutdata )['contracts' ]
43
+
44
+ output = json .loads (stdoutdata )
45
+
46
+ if not "contracts" in output :
47
+ # {'sources': {}, 'version': 'xxx'}
48
+ # solc did not pick up any contracts
49
+ raise ContractsNotFound (output )
50
+
51
+ contracts = output ['contracts' ]
43
52
44
53
for _ , data in contracts .items ():
45
54
data ['abi' ] = json .loads (data ['abi' ])
Original file line number Diff line number Diff line change
1
+ import tempfile
2
+
3
+ import pytest
4
+
5
+ from solc import (
6
+ compile_files ,
7
+ )
8
+
9
+ from solc .exceptions import ContractsNotFound
10
+
11
+
12
+ def test_compile_empty_folder ():
13
+ """Execute compile on a folder without contracts."""
14
+
15
+ with tempfile .TemporaryDirectory () as tmpdirname :
16
+ with pytest .raises (ContractsNotFound ):
17
+ compile_files (tmpdirname )
You can’t perform that action at this time.
0 commit comments