Skip to content

Commit

Permalink
Add tests and make sure they run
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCat467 committed Mar 14, 2024
1 parent 73116ad commit 4c69d0e
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -84,6 +84,8 @@ line-length = 79
fix = true

include = ["*.py", "*.pyi", "**/pyproject.toml"]

[tool.ruff.lint]
select = [
"A", # flake8-builtins
"ASYNC", # flake8-async
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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]
Expand Down
65 changes: 65 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4c69d0e

Please sign in to comment.