Skip to content

Commit 9de5e00

Browse files
committed
pm-api branch cleanup
1 parent 34c8830 commit 9de5e00

17 files changed

+490
-253
lines changed

docs/web3.pm.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ Installation
1212

1313
.. warning:: The PM module is still under development, and not all use-cases are currently supported, so it is not included by default in the web3 instance.
1414

15-
You must install the eth-pm module separately, until it is stable. Install with:
16-
17-
.. code-block:: python
18-
19-
pip install --upgrade ethpm
20-
2115
Attaching
2216
---------
2317

@@ -34,4 +28,10 @@ Methods
3428

3529
The following methods are available on the ``web3.pm`` namespace.
3630

37-
TODO: autoclass docstrings once ``web3.pm`` is stable.
31+
.. autoclass:: web3.pm.PM
32+
:members:
33+
34+
.. note:: The ``web3.pm.Registry`` class is not designed to be interacted with directly, rather via the ``web3.pm.PM`` api.
35+
36+
.. autoclass:: web3.pm.Registry
37+
:members:

setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
"eth-abi>=1.2.0,<2.0.0",
7474
"eth-account>=0.2.1,<0.4.0",
7575
"eth-utils>=1.2.0,<2.0.0",
76+
"ethpm>=0.1.4a5,<1",
77+
"pytest-ethereum>=0.1.3a1,<1",
7678
"hexbytes>=0.1.0,<1.0.0",
7779
"lru-dict>=1.1.6,<2.0.0",
7880
"eth-hash[pycryptodome]>=0.2.0,<1.0.0",

tests/core/pm-module/test_ens_integration.py

+6-15
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,18 @@
33
from eth_utils import (
44
to_canonical_address,
55
)
6+
from ethpm import (
7+
ASSETS_DIR,
8+
)
69

710
from ens import ENS
811
from web3 import Web3
912
from web3.exceptions import (
1013
InvalidAddress,
1114
)
12-
13-
try:
14-
from ethpm import (
15-
ASSETS_DIR,
16-
)
17-
from web3.pm import (
18-
PM,
19-
)
20-
except ImportError:
21-
ethpm_installed = False
22-
else:
23-
ethpm_installed = True
15+
from web3.pm import (
16+
PM,
17+
)
2418

2519

2620
def bytes32(val):
@@ -128,15 +122,13 @@ def ens(ens_setup, mocker):
128122
return ens_setup
129123

130124

131-
@pytest.mark.skipif(ethpm_installed is False, reason="ethpm is not installed")
132125
def test_ens_must_be_set_before_ens_methods_can_be_used(ens):
133126
w3 = ens.web3
134127
PM.attach(w3, 'pm')
135128
with pytest.raises(InvalidAddress):
136129
w3.pm.set_registry("tester.eth")
137130

138131

139-
@pytest.mark.skipif(ethpm_installed is False, reason="ethpm is not installed")
140132
def test_web3_ens(ens):
141133
w3 = ens.web3
142134
PM.attach(w3, 'pm')
@@ -155,7 +147,6 @@ def test_web3_ens(ens):
155147
assert manifest_uri.rstrip(b'\x00') == b'1.com'
156148

157149

158-
@pytest.mark.skipif(ethpm_installed is False, reason="ethpm is not installed")
159150
def test_registry_init_with_ens_name(ens):
160151
w3 = ens.web3
161152
PM.attach(w3, 'pm')

tests/core/pm-module/test_pm_init.py

+12-22
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,44 @@
33
from eth_utils import (
44
to_canonical_address,
55
)
6+
from ethpm import (
7+
Package,
8+
)
9+
from ethpm.exceptions import (
10+
InsufficientAssetsError,
11+
)
12+
from ethpm.tools import (
13+
get_manifest as get_ethpm_manifest,
14+
)
615

716
from web3 import Web3
8-
9-
try:
10-
from ethpm import Package # noqa: E402
11-
from ethpm.tools import get_manifest as get_ethpm_manifest
12-
from ethpm.exceptions import (
13-
InsufficientAssetsError,
14-
)
15-
except ImportError:
16-
ethpm_installed = False
17-
else:
18-
ethpm_installed = True
17+
from web3.pm import (
18+
PM,
19+
)
1920

2021

2122
# Returns web3 instance with `pm` module attached
2223
@pytest.fixture
2324
def web3():
2425
w3 = Web3(Web3.EthereumTesterProvider())
2526
w3.eth.defaultAccount = w3.eth.accounts[0]
26-
try:
27-
from web3.pm import PM # noqa: F811
28-
except ModuleNotFoundError as exc:
29-
assert False, "eth-pm import failed because: %s" % exc
3027
PM.attach(w3, 'pm')
3128
return w3
3229

3330

34-
@pytest.mark.skipif(ethpm_installed is False, reason="ethpm is not installed")
3531
def test_pm_init_with_minimal_manifest(web3):
3632
owned_manifest = get_ethpm_manifest('owned', '1.0.1.json')
3733
pm = web3.pm.get_package_from_manifest(owned_manifest)
3834
assert pm.name == 'owned'
3935

4036

41-
@pytest.mark.skipif(ethpm_installed is False, reason="ethpm is not installed")
4237
def test_get_contract_factory_raises_insufficient_assets_error(web3):
4338
insufficient_owned_manifest = get_ethpm_manifest('owned', '1.0.0.json')
4439
owned_package = web3.pm.get_package_from_manifest(insufficient_owned_manifest)
4540
with pytest.raises(InsufficientAssetsError):
4641
owned_package.get_contract_factory('Owned')
4742

4843

49-
@pytest.mark.skipif(ethpm_installed is False, reason="ethpm is not installed")
5044
def test_get_contract_factory_with_valid_owned_manifest(web3):
5145
owned_manifest = get_ethpm_manifest('owned', '1.0.1.json')
5246
owned_package = web3.pm.get_package_from_manifest(owned_manifest)
@@ -58,7 +52,6 @@ def test_get_contract_factory_with_valid_owned_manifest(web3):
5852
assert owned_instance.abi == owned_factory.abi
5953

6054

61-
@pytest.mark.skipif(ethpm_installed is False, reason="ethpm is not installed")
6255
def test_get_contract_factory_with_valid_safe_math_lib_manifest(web3):
6356
safe_math_lib_manifest = get_ethpm_manifest('safe-math-lib', '1.0.1.json')
6457
safe_math_package = web3.pm.get_package_from_manifest(safe_math_lib_manifest)
@@ -70,7 +63,6 @@ def test_get_contract_factory_with_valid_safe_math_lib_manifest(web3):
7063
assert safe_math_instance.functions.safeAdd(1, 2).call() == 3
7164

7265

73-
@pytest.mark.skipif(ethpm_installed is False, reason="ethpm is not installed")
7466
def test_get_contract_factory_with_valid_escrow_manifest(web3):
7567
escrow_manifest = get_ethpm_manifest("escrow", "1.0.2.json")
7668
escrow_package = web3.pm.get_package_from_manifest(escrow_manifest)
@@ -89,7 +81,6 @@ def test_get_contract_factory_with_valid_escrow_manifest(web3):
8981
assert escrow_instance.functions.sender().call() == web3.eth.accounts[0]
9082

9183

92-
@pytest.mark.skipif(ethpm_installed is False, reason="ethpm is not installed")
9384
def test_deploy_a_standalone_package_integration(web3):
9485
standard_token_manifest = get_ethpm_manifest("standard-token", "1.0.1.json")
9586
token_package = web3.pm.get_package_from_manifest(standard_token_manifest)
@@ -104,7 +95,6 @@ def test_deploy_a_standalone_package_integration(web3):
10495
assert total_supply == 100
10596

10697

107-
@pytest.mark.skipif(ethpm_installed is False, reason="ethpm is not installed")
10898
def test_pm_init_with_manifest_uri(web3, monkeypatch):
10999
monkeypatch.setenv(
110100
"ETHPM_IPFS_BACKEND_CLASS", "ethpm.backends.ipfs.DummyIPFSBackend"

0 commit comments

Comments
 (0)