Skip to content

Commit

Permalink
refactor: move constants from tests.backend.test_common to tests.back…
Browse files Browse the repository at this point in the history
…end.constants
  • Loading branch information
ssato committed Jun 9, 2024
1 parent 0f61108 commit 35c27a4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
22 changes: 22 additions & 0 deletions tests/backend/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright (C) 2024 Satoru SATOH <satoru.satoh gmail.com>
# SPDX-License-Identifier: MIT
#
# pylint: disable=missing-docstring
"""Constants for tests.backend.*."""
from __future__ import annotations

import pathlib

from . import common as TT


CURDIR: pathlib.Path = pathlib.Path(__file__).parent

MOD_TYPE: str = "json"
MOD_BACKEND: str = "stdlib"

TEST_FILE = (
CURDIR / "loaders" / MOD_TYPE / f"test_{MOD_TYPE}_{MOD_BACKEND}.py"
)
TEST_DATADIR = TT.common.RESOURCE_DIR / "loaders" / "json.stdlib"
17 changes: 6 additions & 11 deletions tests/backend/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,19 @@
r"""Test cases for Test Data Collecor."""
from __future__ import annotations

import pathlib

import pytest

import anyconfig.backend.json.stdlib as MOD

from . import common as TT


CURDIR: pathlib.Path = pathlib.Path(__file__).parent
TESTFILE = CURDIR / "loaders" / "json" / "test_json_stdlib.py"

TEST_DATADIR = TT.common.RESOURCE_DIR / "loaders" / "json.stdlib"
from .constants import (
MOD_BACKEND, MOD_TYPE, TEST_FILE, TEST_DATADIR
)


@pytest.mark.parametrize(
("testfile", "exp"),
((str(TESTFILE), "json.stdlib"),
((str(TEST_FILE), f"{MOD_TYPE}.{MOD_BACKEND}"),
(__file__, NameError),
),
)
Expand All @@ -37,7 +32,7 @@ def test_get_name(testfile, exp):

@pytest.mark.parametrize(
("testfile", "exp"),
((str(TESTFILE), MOD),
((str(TEST_FILE), MOD),
),
)
def test_get_mod(testfile, exp):
Expand All @@ -46,7 +41,7 @@ def test_get_mod(testfile, exp):

@pytest.mark.parametrize(
("path", "exp"),
((str(TESTFILE), TEST_DATADIR),
((str(TEST_FILE), TEST_DATADIR),
),
)
def test_get_test_resdir(path, exp):
Expand Down

0 comments on commit 35c27a4

Please sign in to comment.