From 91d8d80c68fb972859e1e478d297b24a7de9fcb9 Mon Sep 17 00:00:00 2001 From: trana Date: Wed, 3 Jan 2024 20:46:26 +0100 Subject: [PATCH] Fix "pytest cannot find module": rm __initL__.py, manual sys.path, add pythonpath --- __init__.py | 0 pytest.ini | 1 + tests/advanced_rpc_test.py | 4 ---- tests/basic_rpc_test.py | 4 ---- tests/binary_rpc_test.py | 5 ----- tests/custom_methods_test.py | 4 ---- tests/fast_api_depends_test.py | 4 ---- tests/trigger_flow_test.py | 4 ---- 8 files changed, 1 insertion(+), 25 deletions(-) delete mode 100644 __init__.py diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pytest.ini b/pytest.ini index 16c88ba..e4a4dcb 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,4 @@ # Handling DeprecationWarning 'asyncio_mode' default value [pytest] asyncio_mode = strict +pythonpath = . diff --git a/tests/advanced_rpc_test.py b/tests/advanced_rpc_test.py index 654e970..d82a324 100644 --- a/tests/advanced_rpc_test.py +++ b/tests/advanced_rpc_test.py @@ -1,10 +1,6 @@ import os import sys -# Add parent path to use local src as package for tests -sys.path.append(os.path.abspath(os.path.join( - os.path.dirname(__file__), os.path.pardir))) - import time import asyncio from multiprocessing import Process diff --git a/tests/basic_rpc_test.py b/tests/basic_rpc_test.py index 68b1a87..b82bf19 100644 --- a/tests/basic_rpc_test.py +++ b/tests/basic_rpc_test.py @@ -2,10 +2,6 @@ import os import sys -# Add parent path to use local src as package for tests -sys.path.append(os.path.abspath(os.path.join( - os.path.dirname(__file__), os.path.pardir))) - import asyncio from multiprocessing import Process diff --git a/tests/binary_rpc_test.py b/tests/binary_rpc_test.py index e34c7f9..656716c 100644 --- a/tests/binary_rpc_test.py +++ b/tests/binary_rpc_test.py @@ -2,11 +2,6 @@ import os import sys -# Add parent path to use local src as package for tests -sys.path.append( - os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)) -) - import json from multiprocessing import Process diff --git a/tests/custom_methods_test.py b/tests/custom_methods_test.py index c8937b9..013cb05 100644 --- a/tests/custom_methods_test.py +++ b/tests/custom_methods_test.py @@ -12,10 +12,6 @@ import os import sys -# Add parent path to use local src as package for tests -sys.path.append(os.path.abspath(os.path.join( - os.path.dirname(__file__), os.path.pardir))) - # Configurable PORT = int(os.environ.get("PORT") or "9000") diff --git a/tests/fast_api_depends_test.py b/tests/fast_api_depends_test.py index 07baf0a..8b6868d 100644 --- a/tests/fast_api_depends_test.py +++ b/tests/fast_api_depends_test.py @@ -3,10 +3,6 @@ from websockets.exceptions import InvalidStatusCode -# Add parent path to use local src as package for tests -sys.path.append(os.path.abspath(os.path.join( - os.path.dirname(__file__), os.path.pardir))) - from multiprocessing import Process import pytest diff --git a/tests/trigger_flow_test.py b/tests/trigger_flow_test.py index 4eb1fe7..6c0cfd7 100644 --- a/tests/trigger_flow_test.py +++ b/tests/trigger_flow_test.py @@ -5,10 +5,6 @@ import os import sys -# Add parent path to use local src as package for tests -sys.path.append(os.path.abspath(os.path.join( - os.path.dirname(__file__), os.path.pardir))) - from fastapi_websocket_rpc.utils import gen_uid from fastapi_websocket_rpc.websocket_rpc_endpoint import WebsocketRPCEndpoint from fastapi_websocket_rpc.websocket_rpc_client import WebSocketRpcClient