Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert for POSIX file paths #60

Merged
merged 6 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/test_constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Pytest test suite for the constants module."""

from dataclasses import FrozenInstanceError
from pathlib import Path

import pytest
from hypothesis import given, strategies
Expand Down Expand Up @@ -44,7 +45,7 @@ def test_fuzz_init(directory, configfile, checksfile, extra, yes, no): # noqa:
def test_fuzz_immutable(fs, hr):
"""Use Hypothesis to confirm that attribute's value cannot be re-assigned."""
with pytest.raises(FrozenInstanceError):
fs.Current_Directory = "/new/path"
fs.Current_Directory = str(Path("/new") / Path("path"))
with pytest.raises(FrozenInstanceError):
hr.Yes = "YES"
with pytest.raises(FrozenInstanceError):
Expand Down
9 changes: 5 additions & 4 deletions tests/test_filesystem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Pytest test suite for the filesystem module."""

import pathlib
from pathlib import Path
from unittest.mock import patch

import pytest
Expand All @@ -12,31 +13,31 @@

def test_valid_directory() -> None:
"""Confirm that a valid directory is found."""
directory_str = "./tests/"
directory_str = str(Path("./tests/"))
directory = pathlib.Path(directory_str)
confirmation = filesystem.confirm_valid_directory(directory)
assert confirmation is True


def test_invalid_directory() -> None:
"""Confirm that a valid directory is found."""
directory_str = "./testsNOT/"
directory_str = str(Path("./testsNOT/"))
directory = pathlib.Path(directory_str)
confirmation = filesystem.confirm_valid_directory(directory)
assert confirmation is False


def test_valid_file() -> None:
"""Confirm that a valid directory is found."""
file_str = "./tests/test_filesystem.py"
file_str = str(Path("./tests") / Path("test_filesystem.py"))
this_file = pathlib.Path(file_str)
confirmation = filesystem.confirm_valid_file(this_file)
assert confirmation is True


def test_invalid_file() -> None:
"""Confirm that a valid directory is found."""
file_str = "./tests/test_filesystemNOT.py"
file_str = str(Path("./tests") / Path("test_filesystemNOT.py.py"))
this_file_not = pathlib.Path(file_str)
confirmation = filesystem.confirm_valid_file(this_file_not)
assert confirmation is False
Expand Down
8 changes: 4 additions & 4 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_cli_analyze_correct_arguments_nothing_to_analyze_not_looking(tmpdir):
project_name = "testing"
# create a reference to the internal
# .chasten directory that supports testing
configuration_directory = test_one + "/.chasten"
configuration_directory = test_one / Path(".chasten")
configuration_directory_path = Path(configuration_directory)
configuration_directory_path.mkdir()
configuration_file = configuration_directory_path / "config.yml"
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_cli_analyze_correct_arguments_analyze_chasten_codebase(cwd):
project_name = "testing"
# create a reference to the internal
# .chasten directory that supports testing
configuration_directory = str(cwd) + "/.chasten"
configuration_directory = cwd / Path(".chasten")
result = runner.invoke(
main.cli,
[
Expand All @@ -144,7 +144,7 @@ def test_cli_analyze_incorrect_arguments_no_project(cwd, tmpdir):
test_one = tmpdir.mkdir("test_one")
# create a reference to the internal
# .chasten directory that supports testing
configuration_directory = str(cwd) + "/.chasten"
configuration_directory = cwd / Path(".chasten")
# call the analyze command
result = runner.invoke(
main.cli,
Expand Down Expand Up @@ -297,7 +297,7 @@ def test_fuzz_cli_analyze_single_directory(cwd, directory):
project_name = "testing"
# create a reference to the internal
# .chasten directory that supports testing
configuration_directory = str(cwd) + "/.chasten"
configuration_directory = cwd / Path(".chasten")
result = runner.invoke(
main.cli,
[
Expand Down
Loading