Skip to content

Commit

Permalink
Fix error when aiohttp is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
fkantelberg committed Dec 7, 2023
1 parent 2b66e53 commit f64a2cf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/socket_proxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from .tunnel_client import TunnelClient
from .tunnel_server import TunnelServer

VERSION = "5.0.1"
VERSION = "5.0.2"
9 changes: 6 additions & 3 deletions src/socket_proxy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import os
import sys
from argparse import Namespace
from configparser import ConfigParser
from typing import Optional, Tuple

Expand Down Expand Up @@ -362,7 +363,9 @@ def option_group(parser: argparse.ArgumentParser, server: bool) -> None:
)


def parse_args(args: Optional[Tuple[str]] = None) -> argparse.Namespace:
def parse_args(
args: Optional[Tuple[str]] = None, namespace: Optional[Namespace] = None
) -> Namespace:
parser = utils.ConfigArgumentParser(
formatter_class=CustomHelpFormatter,
prog="",
Expand Down Expand Up @@ -396,7 +399,7 @@ def parse_args(args: Optional[Tuple[str]] = None) -> argparse.Namespace:
option_group(server, True)
logging_group(server)

parsed = parser.parse_args(args)
parsed = parser.parse_args(args, namespace=namespace)
if not getattr(parsed, "config", None) or not parsed.mode:
return parsed

Expand Down Expand Up @@ -448,7 +451,7 @@ def run_server() -> None:


def main(args: Optional[Tuple[str]] = None) -> None:
base.config = parse_args(args)
parse_args(args, namespace=base.config)

utils.configure_logging(base.config.log_file, base.config.log_level)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,22 @@ def test_main(log_mock, parse_mock, server_mock, client_mock):
main.main(())

log_mock.assert_called_once()
parse_mock.assert_called_once_with(())
parse_mock.assert_called_once()
client_mock.assert_not_called()
server_mock.assert_not_called()
parse_mock.reset_mock()

base.config.mode = "client"
main.main(("client",))
parse_mock.assert_called_once_with(("client",))
parse_mock.assert_called_once()
server_mock.assert_not_called()
client_mock.assert_called_once()
client_mock.reset_mock()
parse_mock.reset_mock()

base.config.mode = "server"
main.main(("server",))
parse_mock.assert_called_once_with(("server",))
parse_mock.assert_called_once()
client_mock.assert_not_called()
server_mock.assert_called_once()
server_mock.reset_mock()
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ deps =
pytest-asyncio
pytest-cov
pytest-timeout
pytest-xdist
aiohttp
coverage
depends:
Expand Down

0 comments on commit f64a2cf

Please sign in to comment.