Skip to content

Commit df661ba

Browse files
committed
Ensures only adds network local to commands which utilise that arg.
1 parent aed5a9c commit df661ba

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

tests/e2e_tests/utils.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import inspect
12
import os
23
import re
34
import shutil
@@ -31,20 +32,28 @@ def exec_command(
3132
inputs: list[str] = None,
3233
):
3334
extra_args = extra_args or []
34-
# Ensure if we forget to add `--network ws://127.0.0.1:9945` that it will run still using the local chain
35-
if not any(
36-
(
37-
x in extra_args
38-
for x in (
39-
"--network",
40-
"--chain",
41-
"--subtensor.network",
42-
"--subtensor.chain_endpoint",
43-
)
44-
)
45-
):
46-
extra_args.extend(["--network", "ws://127.0.0.1:9945"])
4735
cli_manager = CLIManager()
36+
for group in cli_manager.app.registered_groups:
37+
if group.name == command:
38+
for command_ in group.typer_instance.registered_commands:
39+
if command_.name == sub_command:
40+
if "network" in inspect.getcallargs(
41+
command_.callback
42+
).keys() and not any(
43+
(
44+
x in extra_args
45+
for x in (
46+
"--network",
47+
"--chain",
48+
"--subtensor.network",
49+
"--subtensor.chain_endpoint",
50+
)
51+
)
52+
):
53+
# Ensure if we forget to add `--network ws://127.0.0.1:9945` that it will run still
54+
# using the local chain
55+
extra_args.extend(["--network", "ws://127.0.0.1:9945"])
56+
4857
# Capture stderr separately from stdout
4958
runner = CliRunner(mix_stderr=False)
5059
# Prepare the command arguments

0 commit comments

Comments
 (0)