Skip to content

Commit

Permalink
fix ruff findings
Browse files Browse the repository at this point in the history
  • Loading branch information
leon1995 committed Nov 15, 2024
1 parent 82cbeee commit b88829a
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions examples/ReferenceTestV2/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,41 @@
import threading
import uuid

from examples.ReferenceTestV2 import reference_consumer_v2, reference_provider_v2
from sdc11073 import network

from examples.ReferenceTestV2 import reference_provider_v2, reference_consumer_v2


def setup(tls: bool):
os.environ['ref_search_epr'] = str(uuid.uuid4())
if platform.system() == 'Darwin':
os.environ['ref_ip'] = next(str(adapter.ip) for adapter in network.get_adapters() if not adapter.is_loopback)
"""Setups the run."""
os.environ["ref_search_epr"] = str(uuid.uuid4()) # noqa: SIM112
if platform.system() == "Darwin":
os.environ["ref_ip"] = next(str(adapter.ip) for adapter in network.get_adapters() if not adapter.is_loopback) # noqa: SIM112
else:
os.environ['ref_ip'] = next(str(adapter.ip) for adapter in network.get_adapters() if adapter.is_loopback)
os.environ["ref_ip"] = next(str(adapter.ip) for adapter in network.get_adapters() if adapter.is_loopback) # noqa: SIM112
if tls:
certs_path = pathlib.Path(__file__).parent.parent.joinpath('certs')
certs_path = pathlib.Path(__file__).parent.parent.joinpath("certs")
assert certs_path.exists()
os.environ['ref_ca'] = str(certs_path)
os.environ['ref_ssl_passwd'] = 'dummypass'
os.environ["ref_ca"] = str(certs_path) # noqa: SIM112
os.environ["ref_ssl_passwd"] = "dummypass" # noqa: S105,SIM112


def run() -> reference_consumer_v2.ResultsCollector:
"""Run tests."""
threading.Thread(target=reference_provider_v2.run_provider, daemon=True).start()
return reference_consumer_v2.run_ref_test(reference_consumer_v2.ResultsCollector())


def main(tls: bool):
def main(tls: bool) -> reference_consumer_v2.ResultsCollector:
"""Setups and run tests."""
setup(tls)
return run()


if __name__ == '__main__':
if __name__ == "__main__":
import argparse

parser = argparse.ArgumentParser(description='run plug-a-thon tests')
parser.add_argument('--tls', action='store_true', help='Indicates whether tls encryption should be enabled.')
parser = argparse.ArgumentParser(description="run plug-a-thon tests")
parser.add_argument("--tls", action="store_true", help="Indicates whether tls encryption should be enabled.")

args = parser.parse_args()
run_results = main(tls=args.tls)
Expand Down

0 comments on commit b88829a

Please sign in to comment.