diff --git a/pyproject.toml b/pyproject.toml index 0bd2172..a67bf86 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,7 @@ warn_unreachable = true warn_unused_configs = true warn_unused_ignores = true -[tool.ruff.isort] +[tool.ruff.lint.isort] combine-as-imports = true [tool.pycln] @@ -84,6 +84,8 @@ line-length = 79 fix = true include = ["*.py", "*.pyi", "**/pyproject.toml"] + +[tool.ruff.lint] select = [ "A", # flake8-builtins "ASYNC", # flake8-async @@ -121,6 +123,13 @@ extend-ignore = [ "SIM117", # Use multiple with statements at the same time ] +[tool.ruff.lint.per-file-ignores] +"tests/*" = [ + "D100", # undocumented-public-module + "D103", # undocumented-public-function + "D107", # Missing docstring +] + [tool.pytest.ini_options] addopts = "--cov-report term-missing --cov=fix_lwjgl" testpaths = [ @@ -158,7 +167,7 @@ partial_branches = [ [tool.tox] legacy_tox_ini = """ [tox] - envlist = py311, mypy + envlist = py38, py39, py310, py311, py312, mypy, pytest isolated_build = false [gh-actions] diff --git a/tests/test_init.py b/tests/test_init.py new file mode 100644 index 0000000..bd4cc8f --- /dev/null +++ b/tests/test_init.py @@ -0,0 +1,65 @@ +from __future__ import annotations + +import os + +import fix_lwjgl +import pytest + + +def test_get_paths() -> None: + assert fix_lwjgl.get_paths( + { + "": [ + "main.py", + "waffles.txt", + ], + "folder": { + "": [ + "folder_one.txt", + ], + "inner": { + "": [ + "folder_two.txt", + ], + "inner_two": [ + "folder_three.txt", + ], + }, + }, + }, + ) == [ + "main.py", + "waffles.txt", + os.path.join("folder", "folder_one.txt"), + os.path.join("folder", "inner", "folder_two.txt"), + os.path.join("folder", "inner", "inner_two", "folder_three.txt"), + ] + + +def test_get_address() -> None: + assert ( + fix_lwjgl.get_address("CoolCat467", "fix-lwjgl", "HEAD", "README.md") + == "https://raw.githubusercontent.com/CoolCat467/fix-lwjgl/HEAD/README.md" + ) + + +def test_get_lwjgl_file_url() -> None: + assert ( + fix_lwjgl.get_lwjgl_file_url("bin/lwjgl/lwjgl.jar") + == "https://build.lwjgl.org/release/latest/bin/lwjgl/lwjgl.jar" + ) + + +@pytest.mark.parametrize( + ("version", "expected"), + [ + ("17w43b", 3), + ("17w42b", 2), + ("1.12.2", 2), + ("1.13.0", 3), + ("1.7.10", 2), + ("1.20.1", 3), + ], +) +def test_discover_lwjgl_version(version: str, expected: int) -> None: + assert fix_lwjgl.discover_lwjgl_version(version) == expected