From b6537a50ae28935c18a3b89dda5af5bb83413939 Mon Sep 17 00:00:00 2001 From: profitroll Date: Sun, 6 Aug 2023 02:08:02 +0200 Subject: [PATCH] Changed path to tests/ --- tests/test_config_async.py | 15 +++++++++++---- tests/test_config_sync.py | 15 +++++++++++---- tests/test_json_async.py | 12 ++++++------ tests/test_json_sync.py | 12 ++++++------ 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/tests/test_config_async.py b/tests/test_config_async.py index ffe1ed0..c907a79 100644 --- a/tests/test_config_async.py +++ b/tests/test_config_async.py @@ -1,3 +1,4 @@ +from pathlib import Path from typing import Any, List import pytest @@ -14,7 +15,10 @@ from libbot import config_get, config_set ], ) async def test_config_get_valid(args: List[str], expected: str): - assert await config_get(args[0], *args[1:]) == expected + assert ( + await config_get(args[0], *args[1:], config_file=Path("tests/config.json")) + == expected + ) @pytest.mark.asyncio @@ -26,7 +30,10 @@ async def test_config_get_valid(args: List[str], expected: str): ) async def test_config_get_invalid(args: List[str], expected: Any): with expected: - assert await config_get(args[0], *args[1:]) == expected + assert ( + await config_get(args[0], *args[1:], config_file=Path("tests/config.json")) + == expected + ) @pytest.mark.asyncio @@ -38,5 +45,5 @@ async def test_config_get_invalid(args: List[str], expected: Any): ], ) async def test_config_set(key: str, path: List[str], value: Any): - await config_set(key, value, *path) - assert await config_get(key, *path) == value + await config_set(key, value, *path, config_file=Path("tests/config.json")) + assert await config_get(key, *path, config_file=Path("tests/config.json")) == value diff --git a/tests/test_config_sync.py b/tests/test_config_sync.py index b675894..b5184fd 100644 --- a/tests/test_config_sync.py +++ b/tests/test_config_sync.py @@ -1,3 +1,4 @@ +from pathlib import Path from typing import Any, List import pytest @@ -13,7 +14,10 @@ from libbot import sync ], ) def test_config_get_valid(args: List[str], expected: str): - assert sync.config_get(args[0], *args[1:]) == expected + assert ( + sync.config_get(args[0], *args[1:], config_file=Path("tests/config.json")) + == expected + ) @pytest.mark.parametrize( @@ -24,7 +28,10 @@ def test_config_get_valid(args: List[str], expected: str): ) def test_config_get_invalid(args: List[str], expected: Any): with expected: - assert sync.config_get(args[0], *args[1:]) == expected + assert ( + sync.config_get(args[0], *args[1:], config_file=Path("tests/config.json")) + == expected + ) @pytest.mark.parametrize( @@ -35,5 +42,5 @@ def test_config_get_invalid(args: List[str], expected: Any): ], ) def test_config_set(key: str, path: List[str], value: Any): - sync.config_set(key, value, *path) - assert sync.config_get(key, *path) == value + sync.config_set(key, value, *path, config_file=Path("tests/config.json")) + assert sync.config_get(key, *path, config_file=Path("tests/config.json")) == value diff --git a/tests/test_json_async.py b/tests/test_json_async.py index 30dbf58..e8dacdc 100644 --- a/tests/test_json_async.py +++ b/tests/test_json_async.py @@ -12,13 +12,13 @@ from libbot import json_read, json_write "path, expected", [ ( - "data/test.json", + "tests/data/test.json", { "foo": "bar", "abcdefg": ["higklmnop", {"lol": {"kek": [1.0000035, 0.2542, 1337]}}], }, ), - ("data/empty.json", {}), + ("tests/data/empty.json", {}), ], ) async def test_json_read_valid(path: Union[str, Path], expected: Any): @@ -29,8 +29,8 @@ async def test_json_read_valid(path: Union[str, Path], expected: Any): @pytest.mark.parametrize( "path, expected", [ - ("data/invalid.json", pytest.raises(JSONDecodeError)), - ("data/nonexistent.json", pytest.raises(FileNotFoundError)), + ("tests/data/invalid.json", pytest.raises(JSONDecodeError)), + ("tests/data/nonexistent.json", pytest.raises(FileNotFoundError)), ], ) async def test_json_read_invalid(path: Union[str, Path], expected: Any): @@ -47,9 +47,9 @@ async def test_json_read_invalid(path: Union[str, Path], expected: Any): "foo": "bar", "abcdefg": ["higklmnop", {"lol": {"kek": [1.0000035, 0.2542, 1337]}}], }, - "data/test.json", + "tests/data/test.json", ), - ({}, "data/empty.json"), + ({}, "tests/data/empty.json"), ], ) async def test_json_write(data: Any, path: Union[str, Path]): diff --git a/tests/test_json_sync.py b/tests/test_json_sync.py index f230788..88765c9 100644 --- a/tests/test_json_sync.py +++ b/tests/test_json_sync.py @@ -11,13 +11,13 @@ from libbot import sync "path, expected", [ ( - "data/test.json", + "tests/data/test.json", { "foo": "bar", "abcdefg": ["higklmnop", {"lol": {"kek": [1.0000035, 0.2542, 1337]}}], }, ), - ("data/empty.json", {}), + ("tests/data/empty.json", {}), ], ) def test_json_read_valid(path: Union[str, Path], expected: Any): @@ -27,8 +27,8 @@ def test_json_read_valid(path: Union[str, Path], expected: Any): @pytest.mark.parametrize( "path, expected", [ - ("data/invalid.json", pytest.raises(JSONDecodeError)), - ("data/nonexistent.json", pytest.raises(FileNotFoundError)), + ("tests/data/invalid.json", pytest.raises(JSONDecodeError)), + ("tests/data/nonexistent.json", pytest.raises(FileNotFoundError)), ], ) def test_json_read_invalid(path: Union[str, Path], expected: Any): @@ -44,9 +44,9 @@ def test_json_read_invalid(path: Union[str, Path], expected: Any): "foo": "bar", "abcdefg": ["higklmnop", {"lol": {"kek": [1.0000035, 0.2542, 1337]}}], }, - "data/test.json", + "tests/data/test.json", ), - ({}, "data/empty.json"), + ({}, "tests/data/empty.json"), ], ) def test_json_write(data: Any, path: Union[str, Path]):