瀏覽代碼

add libsass to the dev deps (#4982)

* add libsass to the dev deps

* fix test compiler

* do b and a

* skip tests on windows
Khaleel Al-Adhami 2 月之前
父節點
當前提交
4529f7c576
共有 3 個文件被更改,包括 25 次插入7 次删除
  1. 1 0
      pyproject.toml
  2. 9 7
      tests/units/compiler/test_compiler.py
  3. 15 0
      uv.lock

+ 1 - 0
pyproject.toml

@@ -158,6 +158,7 @@ dev = [
   "pytest-playwright >=0.5.1",
   "pytest-retry >=1.7.0,<2.0",
   "pytest-split >=0.10.0,<1.0",
+  "libsass >=0.23.0,<1.0",
   "ruff ==0.9.10",
   "selenium >=4.11.0,<5.0",
   "toml >=0.10.2,<1.0",

+ 9 - 7
tests/units/compiler/test_compiler.py

@@ -1,3 +1,5 @@
+import importlib.util
+import os
 from pathlib import Path
 
 import pytest
@@ -145,12 +147,12 @@ def test_compile_stylesheets(tmp_path: Path, mocker):
 
 
 def test_compile_stylesheets_scss_sass(tmp_path: Path, mocker):
-    try:
-        import sass  # noqa: F401
-    except ImportError:
+    if importlib.util.find_spec("sass") is None:
         pytest.skip(
             'The `libsass` package is required to compile sass/scss stylesheet files. Run `pip install "libsass>=0.23.0"`.'
         )
+    if os.name == "nt":
+        pytest.skip("Skipping test on Windows")
 
     project = tmp_path / "test_project"
     project.mkdir()
@@ -182,8 +184,8 @@ def test_compile_stylesheets_scss_sass(tmp_path: Path, mocker):
         str(Path(".web") / "styles" / "styles.css"),
         "@import url('./tailwind.css'); \n"
         "@import url('./styles.css'); \n"
-        "@import url('./preprocess/styles_a.css'); \n"
-        "@import url('./preprocess/styles_b.css'); \n",
+        f"@import url('./{Path('preprocess') / Path('styles_a.css')!s}'); \n"
+        f"@import url('./{Path('preprocess') / Path('styles_b.css')!s}'); \n",
     )
 
     stylesheets = [
@@ -195,8 +197,8 @@ def test_compile_stylesheets_scss_sass(tmp_path: Path, mocker):
         str(Path(".web") / "styles" / "styles.css"),
         "@import url('./tailwind.css'); \n"
         "@import url('./styles.css'); \n"
-        "@import url('./preprocess/styles_b.css'); \n"
-        "@import url('./preprocess/styles_a.css'); \n",
+        f"@import url('./{Path('preprocess') / Path('styles_b.css')!s}'); \n"
+        f"@import url('./{Path('preprocess') / Path('styles_a.css')!s}'); \n",
     )
 
     assert (project / ".web" / "styles" / "styles.css").read_text() == (

+ 15 - 0
uv.lock

@@ -743,6 +743,19 @@ wheels = [
     { url = "https://files.pythonhosted.org/packages/83/60/d497a310bde3f01cb805196ac61b7ad6dc5dcf8dce66634dc34364b20b4f/lazy_loader-0.4-py3-none-any.whl", hash = "sha256:342aa8e14d543a154047afb4ba8ef17f5563baad3fc610d7b15b213b0f119efc", size = 12097 },
 ]
 
+[[package]]
+name = "libsass"
+version = "0.23.0"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/79/b4/ab091585eaa77299558e3289ca206846aefc123fb320b5656ab2542c20ad/libsass-0.23.0.tar.gz", hash = "sha256:6f209955ede26684e76912caf329f4ccb57e4a043fd77fe0e7348dd9574f1880", size = 316068 }
+wheels = [
+    { url = "https://files.pythonhosted.org/packages/e5/13/fc1bea1de880ca935137183727c7d4dd921c4128fc08b8ddc3698ba5a8a3/libsass-0.23.0-cp38-abi3-macosx_11_0_x86_64.whl", hash = "sha256:34cae047cbbfc4ffa832a61cbb110f3c95f5471c6170c842d3fed161e40814dc", size = 1086783 },
+    { url = "https://files.pythonhosted.org/packages/55/2f/6af938651ff3aec0a0b00742209df1172bc297fa73531f292801693b7315/libsass-0.23.0-cp38-abi3-macosx_14_0_arm64.whl", hash = "sha256:ea97d1b45cdc2fc3590cb9d7b60f1d8915d3ce17a98c1f2d4dd47ee0d9c68ce6", size = 982759 },
+    { url = "https://files.pythonhosted.org/packages/fd/5a/eb5b62641df0459a3291fc206cf5bd669c0feed7814dded8edef4ade8512/libsass-0.23.0-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:4a218406d605f325d234e4678bd57126a66a88841cb95bee2caeafdc6f138306", size = 9444543 },
+    { url = "https://files.pythonhosted.org/packages/e5/fc/275783f5120970d859ae37d04b6a60c13bdec2aa4294b9dfa8a37b5c2513/libsass-0.23.0-cp38-abi3-win32.whl", hash = "sha256:31e86d92a5c7a551df844b72d83fc2b5e50abc6fbbb31e296f7bebd6489ed1b4", size = 775481 },
+    { url = "https://files.pythonhosted.org/packages/ef/20/caf3c7cf2432d85263119798c45221ddf67bdd7dae8f626d14ff8db04040/libsass-0.23.0-cp38-abi3-win_amd64.whl", hash = "sha256:a2ec85d819f353cbe807432d7275d653710d12b08ec7ef61c124a580a8352f3c", size = 872914 },
+]
+
 [[package]]
 name = "mako"
 version = "1.3.9"
@@ -1727,6 +1740,7 @@ dev = [
     { name = "darglint" },
     { name = "dill" },
     { name = "granian", extra = ["reload"] },
+    { name = "libsass" },
     { name = "numpy" },
     { name = "pandas" },
     { name = "pillow" },
@@ -1788,6 +1802,7 @@ dev = [
     { name = "darglint", specifier = ">=1.8.1,<2.0" },
     { name = "dill", specifier = ">=0.3.8" },
     { name = "granian", extras = ["reload"], specifier = ">=2.0.0" },
+    { name = "libsass", specifier = ">=0.23.0,<1.0" },
     { name = "numpy", specifier = ">=2.2.3,<3.0" },
     { name = "pandas", specifier = ">=2.1.1,<3.0" },
     { name = "pillow", specifier = ">=10.0.0,<12.0" },