Skip to content

Commit 208c7ae

Browse files
committed
Use idiomatic fluid API when testing builders
1 parent f257d49 commit 208c7ae

3 files changed

Lines changed: 29 additions & 17 deletions

File tree

tests/builder/test_mamba.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pathlib import Path
88

99

10-
from appose.builder import DynamicBuilder
10+
import appose
1111
from appose.builder.mamba import MambaBuilder
1212

1313
from tests.test_base import cowsay_and_assert
@@ -20,7 +20,7 @@
2020
def test_explicit_mamba_builder():
2121
"""Tests explicit mamba builder selection using .builder() method."""
2222
env = (
23-
DynamicBuilder()
23+
appose
2424
.file(str(TEST_RESOURCES / "cowsay.yml"))
2525
.builder("mamba")
2626
.base("target/envs/mamba-cowsay")

tests/builder/test_pixi.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import pytest
1111

12-
from appose.builder import DynamicBuilder
12+
import appose
1313
from appose.builder.pixi import PixiBuilder
1414

1515
from tests.test_base import cowsay_and_assert
@@ -22,7 +22,7 @@
2222
def test_conda():
2323
"""Tests the builder-agnostic API with an environment.yml file."""
2424
env = (
25-
DynamicBuilder()
25+
appose
2626
.file(str(TEST_RESOURCES / "cowsay.yml"))
2727
.base("target/envs/conda-cowsay")
2828
.log_debug()
@@ -35,7 +35,8 @@ def test_conda():
3535
def test_pixi():
3636
"""Tests building from a pixi.toml file."""
3737
env = (
38-
PixiBuilder()
38+
appose
39+
.pixi()
3940
.file(str(TEST_RESOURCES / "cowsay-pixi.toml"))
4041
.base("target/envs/pixi-cowsay")
4142
.log_debug()
@@ -48,7 +49,8 @@ def test_pixi():
4849
def test_pixi_builder_api():
4950
"""Tests the programmatic builder API for pixi."""
5051
env = (
51-
PixiBuilder()
52+
appose
53+
.pixi()
5254
.conda("python>=3.8", "appose")
5355
.pypi("cowsay==6.1")
5456
.base("target/envs/pixi-cowsay-builder")
@@ -66,7 +68,7 @@ def test_pixi_vacuous():
6668
shutil.rmtree(base)
6769

6870
with pytest.raises(Exception): # Should raise IllegalStateException equivalent
69-
PixiBuilder().base(base).log_debug().build()
71+
appose.pixi().base(base).log_debug().build()
7072

7173

7274
def test_pixi_appose_requirement():
@@ -77,7 +79,8 @@ def test_pixi_appose_requirement():
7779

7880
with pytest.raises(Exception): # Should raise IllegalStateException equivalent
7981
(
80-
PixiBuilder()
82+
appose
83+
.pixi()
8184
.conda("python")
8285
.pypi("cowsay==6.1")
8386
.base(base)
@@ -89,7 +92,8 @@ def test_pixi_appose_requirement():
8992
def test_pixi_pyproject():
9093
"""Tests building from a pyproject.toml with pixi config."""
9194
env = (
92-
PixiBuilder()
95+
appose
96+
.pixi()
9397
.file(str(TEST_RESOURCES / "cowsay-pixi-pyproject.toml"))
9498
.base("target/envs/pixi-cowsay-pyproject")
9599
.log_debug()
@@ -115,7 +119,8 @@ def test_content_api():
115119
"""
116120

117121
env = (
118-
PixiBuilder()
122+
appose
123+
.pixi()
119124
.content(pixi_toml)
120125
.base("target/envs/pixi-content-test")
121126
.log_debug()
@@ -139,7 +144,7 @@ def test_content_environment_yml():
139144
"""
140145

141146
env = (
142-
DynamicBuilder()
147+
appose
143148
.content(env_yml)
144149
.base("target/envs/content-env-yml")
145150
.log_debug()
@@ -157,7 +162,8 @@ def test_build_installs_env():
157162
not only after the first pixi run invocation.
158163
"""
159164
env = (
160-
PixiBuilder()
165+
appose
166+
.pixi()
161167
.file(str(TEST_RESOURCES / "cowsay-pixi.toml"))
162168
.base("target/envs/pixi-build-installs-env")
163169
.log_debug()
@@ -175,7 +181,8 @@ def test_build_installs_env():
175181
def test_pixi_environment_selection():
176182
"""Tests that .environment() selects a non-default pixi environment."""
177183
env = (
178-
PixiBuilder()
184+
appose
185+
.pixi()
179186
.file(str(TEST_RESOURCES / "cowsay-multi-env.toml"))
180187
.base("target/envs/pixi-multi-env")
181188
.environment("alt")
@@ -213,7 +220,7 @@ def test_content_pixi_toml():
213220
"""
214221

215222
env = (
216-
DynamicBuilder()
223+
appose
217224
.content(pixi_toml)
218225
.base("target/envs/content-pixi-toml")
219226
.log_debug()

tests/builder/test_uv.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pathlib import Path
88

99

10+
import appose
1011
from appose.builder.uv import UvBuilder
1112

1213
from tests.test_base import cowsay_and_assert
@@ -19,7 +20,8 @@
1920
def test_uv():
2021
"""Tests building from a requirements.txt file."""
2122
env = (
22-
UvBuilder()
23+
appose
24+
.uv()
2325
.file(str(TEST_RESOURCES / "cowsay-requirements.txt"))
2426
.base("target/envs/uv-cowsay")
2527
.log_debug()
@@ -32,7 +34,8 @@ def test_uv():
3234
def test_uv_builder_api():
3335
"""Tests the programmatic builder API for uv."""
3436
env = (
35-
UvBuilder()
37+
appose
38+
.uv()
3639
.include("cowsay==6.1")
3740
.base("target/envs/uv-cowsay-builder")
3841
.log_debug()
@@ -45,10 +48,12 @@ def test_uv_builder_api():
4548
def test_uv_pyproject():
4649
"""Tests building from a pyproject.toml file."""
4750
env = (
48-
UvBuilder()
51+
appose
52+
.uv()
4953
.file(str(TEST_RESOURCES / "cowsay-pyproject.toml"))
5054
.base("target/envs/uv-cowsay-pyproject")
5155
.log_debug()
5256
.build()
5357
)
58+
assert isinstance(env.builder(), UvBuilder)
5459
cowsay_and_assert(env, "pyproject")

0 commit comments

Comments
 (0)