mirror of
https://github.com/EDCD/EDDN.git
synced 2025-05-04 17:11:05 +03:00
tests: Move fixtures to conftest.py, and use in all existing applicable tests
This commit is contained in:
parent
bc5f7e9059
commit
b4deb19e6e
@ -1,4 +1,6 @@
|
||||
"""General pytest configuration, including fixtures."""
|
||||
import os
|
||||
import sys
|
||||
from typing import Callable, Optional
|
||||
|
||||
import pytest
|
||||
@ -53,3 +55,25 @@ def eddn_message() -> Callable:
|
||||
return test_messages.get(msg_type)
|
||||
|
||||
return _method
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fix_sys_path() -> None:
|
||||
"""Set up an eddn.Gateway import."""
|
||||
# Tests don't include the directory that `pytest` is run from on sys.path
|
||||
sys.path.append(os.getcwd())
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def eddn_gateway():
|
||||
"""Set up an eddn.Gateway import."""
|
||||
import eddn.Gateway
|
||||
|
||||
class CLArgs:
|
||||
config = False
|
||||
|
||||
cl_args = CLArgs()
|
||||
eddn.Gateway.load_config(cl_args)
|
||||
eddn.Gateway.configure()
|
||||
|
||||
return eddn.Gateway
|
||||
|
@ -1,32 +1,6 @@
|
||||
"""Tests for eddn.Gateway.parse_and_error_handle."""
|
||||
import os
|
||||
import sys
|
||||
from typing import Callable
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fix_sys_path() -> None:
|
||||
"""Set up an eddn.Gateway import."""
|
||||
# Tests don't include the directory that `pytest` is run from on sys.path
|
||||
sys.path.append(os.getcwd())
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def eddn_gateway():
|
||||
"""Set up an eddn.Gateway import."""
|
||||
import eddn.Gateway
|
||||
|
||||
class CLArgs:
|
||||
config = False
|
||||
|
||||
cl_args = CLArgs()
|
||||
eddn.Gateway.load_config(cl_args)
|
||||
eddn.Gateway.configure()
|
||||
|
||||
return eddn.Gateway
|
||||
|
||||
|
||||
def test_invalid_json(fix_sys_path, eddn_gateway, eddn_message: Callable) -> None:
|
||||
"""Test invalid JSON input."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user