-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathtest_version_module.py
58 lines (47 loc) · 1.29 KB
/
test_version_module.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import pytest
from web3 import (
EthereumTesterProvider,
Web3,
)
from web3.eth import (
Eth,
)
from web3.providers.eth_tester.main import (
AsyncEthereumTesterProvider,
)
from web3.version import (
AsyncVersion,
BlockingVersion,
Version,
)
# This file is being left in since the Version module is
# being experimented on for async behavior. But, this file
# along with web3/version.py should be removed eventually.
@pytest.fixture
def blocking_w3():
return Web3(
EthereumTesterProvider(),
modules={
"blocking_version": (BlockingVersion,),
"legacy_version": (Version,),
"eth": (Eth,),
},
)
@pytest.fixture
def async_w3():
return Web3(
AsyncEthereumTesterProvider(),
middlewares=[],
modules={
"async_version": (AsyncVersion,),
},
)
def test_legacy_version_deprecation(blocking_w3):
with pytest.raises(DeprecationWarning):
blocking_w3.legacy_version.node
with pytest.raises(DeprecationWarning):
blocking_w3.legacy_version.ethereum
@pytest.mark.asyncio
async def test_async_blocking_version(async_w3, blocking_w3):
assert async_w3.async_version.api == blocking_w3.api
assert await async_w3.async_version.node == blocking_w3.client_version