From 4688cde57348c3cd7db0ca5bf4353cb6e0984c50 Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Sat, 2 Jul 2022 20:12:28 -0400 Subject: [PATCH] Cleaning up imports --- tests/test_utils.py | 31 +++++++++++++++---------------- tests/utils.py | 4 ++-- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 33205e4..0a9e972 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,6 +1,5 @@ import json - -from pathlib import Path +import pathlib from transpose import version, DEFAULT_CACHE_FILENAME from transpose.utils import check_path, create_cache, get_cache, move, remove, symlink @@ -11,11 +10,11 @@ from .utils import CACHE_FILE_CONTENTS, STORE_DIR, SYMLINK_DIR, TARGET_DIR, setu @setup_env() def test_check_path(): - existing_dir = Path(TARGET_DIR) - nonexisting_dir = Path("nonexistent") - symlink_dir = Path(SYMLINK_DIR) + existing_dir = pathlib.Path(TARGET_DIR) + nonexisting_dir = pathlib.Path("nonexistent") + symlink_dir = pathlib.Path(SYMLINK_DIR) - cache_path = Path(TARGET_DIR).joinpath(DEFAULT_CACHE_FILENAME) + cache_path = pathlib.Path(TARGET_DIR).joinpath(DEFAULT_CACHE_FILENAME) assert check_path(existing_dir) is True assert check_path(nonexisting_dir) is False @@ -27,8 +26,8 @@ def test_check_path(): def test_cache_create(): cache_file = "test_cache_file.json" - cache_path = Path(TARGET_DIR).joinpath(cache_file) - original_path = Path("/tmp/some/random/path") + cache_path = pathlib.Path(TARGET_DIR).joinpath(cache_file) + original_path = pathlib.Path("/tmp/some/random/path") create_cache(cache_path=cache_path, original_path=original_path) @@ -41,7 +40,7 @@ def test_cache_create(): @setup_env() def test_cache_get(): - cache_path = Path(TARGET_DIR).joinpath(DEFAULT_CACHE_FILENAME) + cache_path = pathlib.Path(TARGET_DIR).joinpath(DEFAULT_CACHE_FILENAME) cache = get_cache(cache_path) assert cache["version"] == CACHE_FILE_CONTENTS["version"] @@ -50,8 +49,8 @@ def test_cache_get(): @setup_env() def test_file_move(): - source_path = Path(TARGET_DIR) - destination_path = Path(STORE_DIR) + source_path = pathlib.Path(TARGET_DIR) + destination_path = pathlib.Path(STORE_DIR) move(source=source_path.absolute(), destination=destination_path.absolute()) assert not source_path.exists() @@ -60,9 +59,9 @@ def test_file_move(): @setup_env() def test_file_remove(): - cache_path = Path(TARGET_DIR).joinpath(DEFAULT_CACHE_FILENAME) - symlink_filepath = Path(TARGET_DIR).joinpath(SYMLINK_DIR) - target_filepath = Path(TARGET_DIR) + cache_path = pathlib.Path(TARGET_DIR).joinpath(DEFAULT_CACHE_FILENAME) + symlink_filepath = pathlib.Path(TARGET_DIR).joinpath(SYMLINK_DIR) + target_filepath = pathlib.Path(TARGET_DIR) remove(path=cache_path) remove(path=symlink_filepath) @@ -76,8 +75,8 @@ def test_file_remove(): @setup_env() def test_file_symlink(): symlink_name = "test_link" - symlink_filepath = Path(symlink_name) - target_filepath = Path(TARGET_DIR) + symlink_filepath = pathlib.Path(symlink_name) + target_filepath = pathlib.Path(TARGET_DIR) symlink(target_path=target_filepath, symlink_path=symlink_filepath) diff --git a/tests/utils.py b/tests/utils.py index 2abe033..7feaa9f 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,8 +1,8 @@ import os import json +import pathlib from contextlib import contextmanager -from pathlib import Path from tempfile import TemporaryDirectory from transpose import DEFAULT_CACHE_FILENAME, version @@ -27,7 +27,7 @@ def setup_env(): os.mkdir(STORE_DIR) os.symlink(TARGET_DIR, SYMLINK_DIR) - cache_path = Path(TARGET_DIR).joinpath(DEFAULT_CACHE_FILENAME) + cache_path = pathlib.Path(TARGET_DIR).joinpath(DEFAULT_CACHE_FILENAME) with open(str(cache_path), "w") as f: json.dump(CACHE_FILE_CONTENTS, f) yield