Skip to content

Commit

Permalink
Parity setMode to snake
Browse files Browse the repository at this point in the history
  • Loading branch information
kclowes committed Apr 28, 2021
1 parent 910f625 commit e0d7dee
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions newsfragments/1954.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``parity.set_mode``, deprecate ``parity.setMode``
10 changes: 7 additions & 3 deletions web3/_utils/module_testing/parity_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,21 @@ class ParitySetModuleTest:
]
)
def test_set_mode(self, web3: "Web3", mode: ParityMode) -> None:
assert web3.parity.setMode(mode) is True
assert web3.parity.set_mode(mode) is True

def test_set_mode_deprecated(self, web3: "Web3", mode: ParityMode) -> None:
with pytest.warns(DeprecationWarning, match="setMode is deprecated in favor of set_mode"):
assert web3.parity.setMode(mode) is True

def test_set_mode_with_bad_string(self, web3: "Web3") -> None:
with pytest.raises(InvalidParityMode, match="Couldn't parse parameters: mode"):
# type ignored b/c it's an invalid literal ParityMode
web3.parity.setMode('not a mode') # type: ignore
web3.parity.set_mode('not a mode') # type: ignore

def test_set_mode_with_no_argument(self, web3: "Web3") -> None:
with pytest.raises(
InvalidParityMode,
match='Invalid params: invalid length 0, expected a tuple of size 1.'
):
# type ignored b/c setMode expects arguments
web3.parity.setMode() # type: ignore
web3.parity.set_mode() # type: ignore
2 changes: 1 addition & 1 deletion web3/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,6 @@ class ContractLogicError(SolidityError, ValueError):
class InvalidParityMode(TypeError, ValueError):
# Inherits from TypeError for backwards compatibility
"""
Raised when web3.parity.setMode() is called with no or invalid args
Raised when web3.parity.set_mode() is called with no or invalid args
"""
pass
3 changes: 2 additions & 1 deletion web3/parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def trace_transactions_munger(
mungers=[trace_transactions_munger],
)

setMode: Method[Callable[[ParityMode], bool]] = Method(
set_mode: Method[Callable[[ParityMode], bool]] = Method(
RPC.parity_setMode,
mungers=[default_root_munger],
)
Expand All @@ -226,6 +226,7 @@ def trace_transactions_munger(
traceReplayTransaction = DeprecatedMethod(trace_replay_transaction, 'traceReplayTransaction',
'trace_replay_transaction')
netPeers = DeprecatedMethod(net_peers, 'netPeers', 'net_peers')
setMode = DeprecatedMethod(set_mode, 'setMode', 'set_mode')
traceBlock = DeprecatedMethod(trace_block, 'traceBlock', 'trace_block')
traceFilter = DeprecatedMethod(trace_filter, 'traceFilter', 'trace_filter')
traceReplayBlockTransactions = DeprecatedMethod(trace_replay_block_transactions,
Expand Down

0 comments on commit e0d7dee

Please sign in to comment.