Skip to content

Commit e3c7feb

Browse files
committed
Remove unnecessary w3 arguments to tests while reviewing PR #2357
1 parent f2672eb commit e3c7feb

14 files changed

+39
-50
lines changed

tests/core/contracts/test_contract_call_interface.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def bytes32_contract(w3, Bytes32Contract, request, address_conversion_func):
150150

151151

152152
@pytest.fixture()
153-
def undeployed_math_contract(w3, MathContract, address_conversion_func):
153+
def undeployed_math_contract(MathContract, address_conversion_func):
154154
empty_address = address_conversion_func("0x000000000000000000000000000000000000dEaD")
155155
_undeployed_math_contract = MathContract(address=empty_address)
156156
return _undeployed_math_contract
@@ -191,7 +191,7 @@ def nested_tuple_contract(w3, NestedTupleContract, address_conversion_func):
191191
return deploy(w3, NestedTupleContract, address_conversion_func)
192192

193193

194-
def test_invalid_address_in_deploy_arg(w3, WithConstructorAddressArgumentsContract):
194+
def test_invalid_address_in_deploy_arg(WithConstructorAddressArgumentsContract):
195195
with pytest.raises(InvalidAddress):
196196
WithConstructorAddressArgumentsContract.constructor(
197197
"0xd3cda913deb6f67967b99d67acdfa1712c293601",
@@ -704,7 +704,7 @@ def test_call_sending_ether_to_nonpayable_function(payable_tester_contract, call
704704
('reflect_short_u', Decimal('25.5')),
705705
),
706706
)
707-
def test_reflect_fixed_value(w3, fixed_reflection_contract, function, value):
707+
def test_reflect_fixed_value(fixed_reflection_contract, function, value):
708708
contract_func = fixed_reflection_contract.functions[function]
709709
reflected = contract_func(value).call({'gas': 420000})
710710
assert reflected == value
@@ -741,7 +741,7 @@ def test_reflect_fixed_value(w3, fixed_reflection_contract, function, value):
741741
('reflect', 0, "Ambiguous argument encoding"),
742742
),
743743
)
744-
def test_invalid_fixed_value_reflections(w3, fixed_reflection_contract, function, value, error):
744+
def test_invalid_fixed_value_reflections(fixed_reflection_contract, function, value, error):
745745
contract_func = fixed_reflection_contract.functions[function]
746746
with pytest.raises(ValidationError, match=error):
747747
contract_func(value).call({'gas': 420000})

tests/core/contracts/test_extracting_event_data.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,6 @@ def test_event_rich_log_with_byte_args(
662662

663663

664664
def test_receipt_processing_with_discard_flag(
665-
w3,
666665
event_contract,
667666
indexed_event_contract,
668667
dup_txn_receipt,
@@ -675,7 +674,6 @@ def test_receipt_processing_with_discard_flag(
675674

676675

677676
def test_receipt_processing_with_ignore_flag(
678-
w3,
679677
event_contract,
680678
indexed_event_contract,
681679
dup_txn_receipt,
@@ -704,7 +702,6 @@ def test_receipt_processing_with_ignore_flag(
704702

705703

706704
def test_receipt_processing_with_warn_flag(
707-
w3,
708705
indexed_event_contract,
709706
dup_txn_receipt):
710707

@@ -716,7 +713,6 @@ def test_receipt_processing_with_warn_flag(
716713

717714

718715
def test_receipt_processing_with_strict_flag(
719-
w3,
720716
indexed_event_contract,
721717
dup_txn_receipt):
722718

@@ -727,7 +723,6 @@ def test_receipt_processing_with_strict_flag(
727723

728724

729725
def test_receipt_processing_with_invalid_flag(
730-
w3,
731726
indexed_event_contract,
732727
dup_txn_receipt):
733728

@@ -738,7 +733,6 @@ def test_receipt_processing_with_invalid_flag(
738733

739734

740735
def test_receipt_processing_with_no_flag(
741-
w3,
742736
indexed_event_contract,
743737
dup_txn_receipt):
744738

@@ -750,7 +744,6 @@ def test_receipt_processing_with_no_flag(
750744

751745

752746
def test_single_log_processing_with_errors(
753-
w3,
754747
indexed_event_contract,
755748
dup_txn_receipt):
756749
event_instance = indexed_event_contract.events.LogSingleWithIndex()

tests/core/contracts/test_implicit_contract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_implicitcontract_call_default(math_contract, get_transaction_count):
6262
assert get_transaction_count("pending") == (blocknum, 0)
6363

6464

65-
def test_implicitcontract_transact_default(w3, math_contract, get_transaction_count):
65+
def test_implicitcontract_transact_default(math_contract, get_transaction_count):
6666
# Use to verify correct operation later on
6767
with pytest.warns(DeprecationWarning, match='deprecated in favor of classic contract syntax'):
6868
start_count = math_contract.counter()

tests/core/filtering/test_contract_createFilter_topic_merging.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import pytest
22

33

4-
def test_merged_topic_list_event(
5-
w3,
6-
emitter,
7-
emitter_event_ids,
8-
wait_for_transaction):
4+
def test_merged_topic_list_event(emitter):
95
manual_topics = [
106
'0xf16c999b533366ca5138d78e85da51611089cd05749f098d6c225d4cd42ee6ec', # event sig
117
'0x0000000000000000000000000000000000000000000000000000000000000457', # 1111

tests/core/filtering/test_contract_on_event_filtering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
@pytest.mark.parametrize('call_as_instance', (True, False))
9-
def test_create_filter_address_parameter(w3, emitter, Emitter, call_as_instance):
9+
def test_create_filter_address_parameter(emitter, Emitter, call_as_instance):
1010
if call_as_instance:
1111
event_filter = emitter.events.LogNoArguments.createFilter(fromBlock="latest")
1212
else:

tests/core/manager/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Wrapper:
1515
def __repr__(self):
1616
return 'middleware-' + key
1717

18-
def __call__(self, make_request, web3):
18+
def __call__(self, make_request, w3):
1919
def middleware_fn(method, params):
2020
params.append(key)
2121
method = "|".join((method, key))

tests/core/manager/test_middleware_can_be_stateful.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
)
77

88

9-
def stateful_middleware(make_request, web3):
9+
def stateful_middleware(make_request, w3):
1010
state = []
1111

1212
def middleware(method, params):

tests/core/mining-module/test_miner_hashrate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55

66
@flaky(max_runs=3)
7-
def test_miner_hashrate(web3_empty, wait_for_miner_start):
8-
web3 = web3_empty
7+
def test_miner_hashrate(w3_empty, wait_for_miner_start):
8+
w3 = w3_empty
99

10-
hashrate = web3.eth.hashrate
10+
hashrate = w3.eth.hashrate
1111
assert hashrate > 0

tests/core/mining-module/test_miner_start.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@
1010

1111

1212
@flaky(max_runs=3)
13-
def test_miner_start(web3_empty, wait_for_miner_start):
14-
web3 = web3_empty
13+
def test_miner_start(w3_empty, wait_for_miner_start):
14+
w3 = w3_empty
1515

1616
# sanity
17-
assert web3.eth.mining
18-
assert web3.eth.hashrate
17+
assert w3.eth.mining
18+
assert w3.eth.hashrate
1919

20-
web3.geth.miner.stop()
20+
w3.geth.miner.stop()
2121

2222
with Timeout(60) as timeout:
23-
while web3.eth.mining or web3.eth.hashrate:
23+
while w3.eth.mining or w3.eth.hashrate:
2424
timeout.sleep(random.random())
2525

26-
assert not web3.eth.mining
27-
assert not web3.eth.hashrate
26+
assert not w3.eth.mining
27+
assert not w3.eth.hashrate
2828

29-
web3.miner.start(1)
29+
w3.miner.start(1)
3030

31-
wait_for_miner_start(web3)
31+
wait_for_miner_start(w3)
3232

33-
assert web3.eth.mining
34-
assert web3.eth.hashrate
33+
assert w3.eth.mining
34+
assert w3.eth.hashrate

tests/core/mining-module/test_miner_stop.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010

1111

1212
@flaky(max_runs=3)
13-
def test_miner_stop(web3_empty):
14-
web3 = web3_empty
13+
def test_miner_stop(w3_empty):
14+
w3 = w3_empty
1515

16-
assert web3.eth.mining
17-
assert web3.eth.hashrate
16+
assert w3.eth.mining
17+
assert w3.eth.hashrate
1818

19-
web3.geth.miner.stop()
19+
w3.geth.miner.stop()
2020

2121
with Timeout(60) as timeout:
22-
while web3.eth.mining or web3.eth.hashrate:
22+
while w3.eth.mining or w3.eth.hashrate:
2323
timeout.sleep(random.random())
2424
timeout.check()
2525

26-
assert not web3.eth.mining
27-
assert not web3.eth.hashrate
26+
assert not w3.eth.mining
27+
assert not w3.eth.hashrate

0 commit comments

Comments
 (0)