From 8c2a0ae95afb1c4a54d6cde5b2d6ae8f2fbe5f9b Mon Sep 17 00:00:00 2001 From: A_D Date: Wed, 26 Jan 2022 20:36:29 +0200 Subject: [PATCH] make tests not explode on windows --- config/linux.py | 2 +- tests/config.py/test_config.py | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/config/linux.py b/config/linux.py index 04087b32..58c0f7cd 100644 --- a/config/linux.py +++ b/config/linux.py @@ -3,7 +3,7 @@ import os import pathlib import sys from configparser import ConfigParser -from typing import List, Optional, Union +from typing import TYPE_CHECKING, List, Optional, Union from config import AbstractConfig, appname, logger diff --git a/tests/config.py/test_config.py b/tests/config.py/test_config.py index 0d10a3c2..4f72d437 100644 --- a/tests/config.py/test_config.py +++ b/tests/config.py/test_config.py @@ -1,4 +1,12 @@ -"""Test the config system.""" +""" +Test the config system. + +Note: These tests to arbitrary reads and writes to an existing config, including +key deletions. Said modifications are to keys that are generated internally. + +Most of these tests are parity tests with the "old" config, and likely one day can be +entirely removed. +""" from __future__ import annotations import contextlib @@ -19,7 +27,7 @@ print(sys.path) from _old_config import old_config # noqa: E402 -from config import LinuxConfig, config # noqa: E402 +from config import config # noqa: E402 def _fuzz_list(length: int) -> List[str]: @@ -77,6 +85,11 @@ class TestNewConfig: def __update_linuxconfig(self) -> None: """On linux config uses ConfigParser, which doesn't update from disk changes. Force the update here.""" + if sys.platform != 'linux': + return + + from config.linux import LinuxConfig + if isinstance(config, LinuxConfig) and config.config is not None: config.config.read(config.filename) @@ -163,6 +176,10 @@ class TestOldNewConfig: def __update_linuxconfig(self) -> None: """On linux config uses ConfigParser, which doesn't update from disk changes. Force the update here.""" + if sys.platform != 'linux': + return + + from config.linux import LinuxConfig if isinstance(config, LinuxConfig) and config.config is not None: config.config.read(config.filename)