Skip to content

Commit

Permalink
Back to pytest for better editor support.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverandrich committed Oct 21, 2023
1 parent ef40b16 commit a61e6ed
Show file tree
Hide file tree
Showing 11 changed files with 1,442 additions and 302 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -16,17 +16,17 @@ repos:
- id: check-json

- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.10.0
hooks:
- id: black

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.292"
rev: "v0.1.1"
hooks:
- id: ruff

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.329
rev: v1.1.332
hooks:
- id: pyright

Expand Down
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"."
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
1,110 changes: 1,110 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ werkzeug = { version = "^3.0.0", optional = true }
[tool.poetry.group.dev.dependencies]
django-types = ">=0.17,<0.19"
mkdocs-material = "^9.3.1"
django-rich = "^1.7.0"
coverage = { extras = ["toml"], version = "^7.3.2" }
pytest = "^7.4.2"
pytest-django = "^4.5.2"
pytest-cov = "^4.1.0"
pytest-mock = "^3.12.0"

[build-system]
requires = ["poetry-core"]
Expand Down Expand Up @@ -137,6 +140,13 @@ ban-relative-imports = "all"
"tests/**/*" = ["PLR2004", "S101", "TID252"]
"tests/snapshots/*" = ["ALL"]

# Pytest
[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "tests.settings"
pythonpath = [".", "src"]
django_find_project = false
markers = ["mock_network_and_subprocess"]

# Coverage
[tool.coverage.run]
source = ["django_tailwind_cli", "tests"]
Expand Down
26 changes: 19 additions & 7 deletions src/django_tailwind_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@
class Config:
"""Configuration for the Tailwind CSS CLI."""

def __init__(self) -> None:
"""Initialize the configuration."""
self.tailwind_version: str = getattr(settings, "TAILWIND_CLI_VERSION", "3.3.3")
self.cli_path: Union[str, None] = getattr(settings, "TAILWIND_CLI_PATH", "~/.local/bin/")
self.src_css: Union[str, None] = getattr(settings, "TAILWIND_CLI_SRC_CSS", None)
self.dist_css: str = getattr(settings, "TAILWIND_CLI_DIST_CSS", "css/tailwind.css")
self.config_file: str = getattr(settings, "TAILWIND_CLI_CONFIG_FILE", "tailwind.config.js")
@property
def tailwind_version(self) -> str:
return getattr(settings, "TAILWIND_CLI_VERSION", "3.3.3")

@property
def cli_path(self) -> Union[str, None]:
return getattr(settings, "TAILWIND_CLI_PATH", "~/.local/bin/")

@property
def src_css(self) -> Union[str, None]:
return getattr(settings, "TAILWIND_CLI_SRC_CSS", None)

@property
def dist_css(self) -> str:
return getattr(settings, "TAILWIND_CLI_DIST_CSS", "css/tailwind.css")

@property
def config_file(self) -> str:
return getattr(settings, "TAILWIND_CLI_CONFIG_FILE", "tailwind.config.js")

def validate_settings(self) -> None:
"""Validate the settings."""
Expand Down
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import pytest

from django_tailwind_cli.utils import Config


@pytest.fixture
def config() -> Config:
return Config()
2 changes: 0 additions & 2 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,4 @@

USE_TZ = True

TEST_RUNNER = "django_rich.test.RichRunner"

SILENCED_SYSTEM_CHECKS = ["staticfiles.W004"]
Loading

0 comments on commit a61e6ed

Please sign in to comment.