Skip to content

Commit 2bbf8e6

Browse files
author
Damon Chen
committed
Fix python lint issues
1 parent 900240b commit 2bbf8e6

File tree

6 files changed

+43
-22
lines changed

6 files changed

+43
-22
lines changed

integration_tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pytest
22

3+
from .expansion import expand_and_output_yamls
34
from .network import setup_cronos, setup_geth
45

5-
from .expansion import expand_and_output_yamls
66

77
def pytest_configure(config):
88
config.addinivalue_line("markers", "slow: marks tests as slow")
@@ -45,7 +45,7 @@ def cronos(tmp_path_factory, yamls):
4545
@pytest.fixture(scope="session")
4646
def geth(tmp_path_factory):
4747
path = tmp_path_factory.mktemp("geth")
48-
yield from setup_geth(path, 8545)
48+
yield from setup_geth(path, 26450)
4949

5050

5151
@pytest.fixture(scope="session", params=["cronos", "geth"])
@@ -61,6 +61,7 @@ def cluster(request, cronos, geth):
6161
else:
6262
raise NotImplementedError
6363

64+
6465
@pytest.fixture(scope="session")
6566
def yamls():
6667
yield expand_and_output_yamls()

integration_tests/expansion.py

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1+
import errno
2+
import os
13
import re
4+
from pathlib import Path
25
from typing import Any, Mapping, Optional, Text
36

4-
from dotenv.variables import parse_variables
5-
67
import yaml
7-
import os
8-
import errno
98
from dotenv import dotenv_values, load_dotenv
10-
from pathlib import Path
11-
import sys
9+
from dotenv.variables import parse_variables
10+
1211

1312
def expand_posix_vars(obj: Any, variables: Mapping[Text, Optional[Any]]) -> Any:
1413
"""expand_posix_vars recursively expands POSIX values in an object.
@@ -63,6 +62,7 @@ def _str_to_python_value(val):
6362
# return int(val)
6463
return val
6564

65+
6666
def expand_yaml(config_path):
6767
def load_system_envvars():
6868
config_vars = dict(os.environ)
@@ -73,11 +73,13 @@ def load_system_envvars():
7373
if "dotenv" in config:
7474
dotenv = config.pop("dotenv", {})
7575
if not isinstance(dotenv, str):
76-
raise ValueError(f'Invalid value passed to dotenv: {dotenv}')
76+
raise ValueError(f"Invalid value passed to dotenv: {dotenv}")
7777
config_vars = load_system_envvars()
7878
env_path = Path(config_path).parent.joinpath(dotenv)
7979
if not env_path.is_file():
80-
raise ValueError(f"Dotenv specified in config but not found at path: {env_path}")
80+
raise ValueError(
81+
f"Dotenv specified in config but not found at path: {env_path}"
82+
)
8183
config_vars.update(dotenv_values(dotenv_path=env_path)) # type: ignore
8284
load_dotenv(dotenv_path=env_path)
8385
config = expand_posix_vars(config, config_vars)
@@ -86,22 +88,35 @@ def load_system_envvars():
8688
if not os.path.exists(output_path.parent):
8789
try:
8890
os.makedirs(output_path.parent)
89-
except OSError as exc: # Guard against race condition
91+
except OSError as exc: # Guard against race condition
9092
if exc.errno != errno.EEXIST:
9193
raise
92-
yaml.dump(config, output_path.open("w+"),)
94+
yaml.dump(
95+
config,
96+
output_path.open("w+"),
97+
)
9398
print(f"{config_path} was expanded as: {output_path}")
9499
return output_path
95100

101+
96102
def expand_and_output_yamls():
97103
yaml_dict = {}
98-
yaml_dict["cronos-devnet"] = expand_yaml(Path(__file__).parent / "../scripts/cronos-devnet.yaml")
99-
yaml_dict["chainmain-devnet"] = expand_yaml(Path(__file__).parent / "../scripts/chainmain-devnet.yaml")
104+
yaml_dict["cronos-devnet"] = expand_yaml(
105+
Path(__file__).parent / "../scripts/cronos-devnet.yaml"
106+
)
107+
yaml_dict["chainmain-devnet"] = expand_yaml(
108+
Path(__file__).parent / "../scripts/chainmain-devnet.yaml"
109+
)
100110
yaml_dict["devnet"] = expand_yaml(Path(__file__).parent / "../scripts/devnet.yaml")
101-
yaml_dict["disable_auto_deployment"] = expand_yaml(Path(__file__).parent / "../scripts/disable_auto_deployment.yaml")
102-
yaml_dict["genesis_token_mapping"] = expand_yaml(Path(__file__).parent / "../scripts/genesis_token_mapping.yaml")
111+
yaml_dict["disable_auto_deployment"] = expand_yaml(
112+
Path(__file__).parent / "../scripts/disable_auto_deployment.yaml"
113+
)
114+
yaml_dict["genesis_token_mapping"] = expand_yaml(
115+
Path(__file__).parent / "../scripts/genesis_token_mapping.yaml"
116+
)
103117
return yaml_dict
104118

119+
105120
if __name__ == "__main__":
106121
expand_and_output_yamls()
107122
# yaml_path = sys.argv[1]

integration_tests/network.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import signal
44
import subprocess
55
import time
6-
from pathlib import Path
76

87
import tomlkit
98
import web3
@@ -83,7 +82,11 @@ def __init__(self, w3):
8382

8483

8584
def setup_cronos(path, base_port, yamls, enable_auto_deployment=True):
86-
cfg = yamls["cronos-devnet"] if enable_auto_deployment else yamls["disable_auto_deployment"]
85+
cfg = (
86+
yamls["cronos-devnet"]
87+
if enable_auto_deployment
88+
else yamls["disable_auto_deployment"]
89+
)
8790

8891
yield from setup_custom_cronos(path, base_port, cfg)
8992

integration_tests/test_gravity.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def geth(tmp_path_factory):
8585
@pytest.fixture(scope="module", params=[True, False])
8686
def cronos(request, tmp_path_factory, yamls):
8787
"start-cronos"
88-
yield from setup_cronos(tmp_path_factory.mktemp("cronos"), 26700, request.param, yamls)
88+
yield from setup_cronos(
89+
tmp_path_factory.mktemp("cronos"), 26700, request.param, yamls
90+
)
8991

9092

9193
@pytest.fixture(scope="module")

integration_tests/test_ibc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
from pathlib import Path
55

66
import pytest
7+
from eth_account import Account
78

89
from .network import setup_chainmain, setup_cronos, setup_hermes
9-
from .utils import wait_for_port, KEYS
10-
from eth_account import Account
10+
from .utils import KEYS, wait_for_port
1111

1212

1313
@pytest.fixture(scope="module")

integration_tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
import toml
1818
import yaml
1919
from dateutil.parser import isoparse
20+
from dotenv import load_dotenv
2021
from eth_account import Account
2122
from hexbytes import HexBytes
2223
from pystarport import cluster, ledger
2324
from pystarport.ports import rpc_port
2425
from web3._utils.transactions import fill_nonce, fill_transaction_defaults
2526

26-
from dotenv import load_dotenv
2727
load_dotenv("../scripts/.env")
2828

2929
KEYS = {

0 commit comments

Comments
 (0)