From cb145d2f8b789dc30dc7198c7400b2c0c37f9a80 Mon Sep 17 00:00:00 2001 From: Morgan Epp <60796713+epmog@users.noreply.github.com> Date: Wed, 28 Feb 2024 19:31:01 -0600 Subject: [PATCH] fix: remove relative import since client can't handle it Signed-off-by: Morgan Epp <60796713+epmog@users.noreply.github.com> --- src/openjd/adaptor_runtime_client/connection.py | 4 ++-- test/openjd/adaptor_runtime/unit/http/test_request_handler.py | 2 +- test/openjd/adaptor_runtime/unit/utils/test_secure_open.py | 4 ++-- .../adaptor_runtime_client/unit/test_client_interface.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/openjd/adaptor_runtime_client/connection.py b/src/openjd/adaptor_runtime_client/connection.py index cfc7f30..ff65224 100644 --- a/src/openjd/adaptor_runtime_client/connection.py +++ b/src/openjd/adaptor_runtime_client/connection.py @@ -5,9 +5,9 @@ import socket as _socket import ctypes as _ctypes import os as _os +from sys import platform from typing import Any from http.client import HTTPConnection as _HTTPConnection -from ..adaptor_runtime._osname import OSName class UnrecognizedBackgroundConnectionError(Exception): @@ -86,7 +86,7 @@ def _authenticate(self) -> bool: peercred_opt_level: Any peercred_opt: Any cred_cls: Any - if OSName.is_macos(): + if platform == "darwin": # SOL_LOCAL is not defined in Python's socket module, need to hardcode it # source: https://github.com/apple-oss-distributions/xnu/blob/1031c584a5e37aff177559b9f69dbd3c8c3fd30a/bsd/sys/un.h#L85 peercred_opt_level = 0 # type: ignore[attr-defined] diff --git a/test/openjd/adaptor_runtime/unit/http/test_request_handler.py b/test/openjd/adaptor_runtime/unit/http/test_request_handler.py index 3d469b8..ac0a117 100644 --- a/test/openjd/adaptor_runtime/unit/http/test_request_handler.py +++ b/test/openjd/adaptor_runtime/unit/http/test_request_handler.py @@ -137,7 +137,7 @@ def test_respond_with_body( mock_wfile.write.assert_called_once_with(body.encode("utf-8")) -@pytest.mark.skipif(not OSName.is_linux() or not OSName.is_macos(), reason="Unix-specific tests") +@pytest.mark.skipif(not OSName.is_posix(), reason="Posix-specific tests") class TestAuthentication: """ Tests for the RequestHandler authentication diff --git a/test/openjd/adaptor_runtime/unit/utils/test_secure_open.py b/test/openjd/adaptor_runtime/unit/utils/test_secure_open.py index 2d48279..7e45384 100644 --- a/test/openjd/adaptor_runtime/unit/utils/test_secure_open.py +++ b/test/openjd/adaptor_runtime/unit/utils/test_secure_open.py @@ -44,8 +44,8 @@ ], ) @patch.object(os, "open") -@pytest.mark.skipif(not OSName.is_linux(), reason="Linux-specific tests") -def test_secure_open_in_linux(mock_os_open, path, open_mode, mask, expected_os_open_kwargs): +@pytest.mark.skipif(not OSName.is_posix(), reason="Posix-specific tests") +def test_secure_open_in_posix(mock_os_open, path, open_mode, mask, expected_os_open_kwargs): # WHEN with patch("builtins.open", mock_open()) as mocked_open: secure_open_kwargs = {"mask": mask} if mask else {} diff --git a/test/openjd/adaptor_runtime_client/unit/test_client_interface.py b/test/openjd/adaptor_runtime_client/unit/test_client_interface.py index b9e315c..98b66a4 100644 --- a/test/openjd/adaptor_runtime_client/unit/test_client_interface.py +++ b/test/openjd/adaptor_runtime_client/unit/test_client_interface.py @@ -51,7 +51,7 @@ def close(self, args: _Optional[_Dict[str, _Any]]) -> None: @pytest.mark.skipif(not OSName.is_posix(), reason="Posix-specific tests") -class TestLinuxClientInterface: +class TestPosixClientInterface: @pytest.mark.parametrize( argnames=("original_path", "new_path"), argvalues=[