Skip to content

Commit 4aeb1df

Browse files
committed
Update test_builder.py
1 parent e0b86a1 commit 4aeb1df

File tree

1 file changed

+35
-20
lines changed

1 file changed

+35
-20
lines changed

tests/unit/plugins/conan/test_builder.py

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pytest
77

88
from cppython.plugins.conan.builder import Builder
9-
from cppython.plugins.conan.schema import ConanDependency, ConanVersion
9+
from cppython.plugins.conan.schema import ConanDependency, ConanfileGenerationData, ConanVersion
1010

1111

1212
class TestBuilder:
@@ -44,13 +44,16 @@ def test_creates_both_files(self, builder: Builder, tmp_path: Path) -> None:
4444
]
4545
dependency_groups = {}
4646

47-
builder.generate_conanfile(
48-
directory=tmp_path,
47+
data = ConanfileGenerationData(
4948
dependencies=dependencies,
5049
dependency_groups=dependency_groups,
5150
name='test-project',
5251
version='1.0.0',
5352
)
53+
builder.generate_conanfile(
54+
directory=tmp_path,
55+
data=data,
56+
)
5457

5558
base_file = tmp_path / 'conanfile_base.py'
5659
conan_file = tmp_path / 'conanfile.py'
@@ -60,37 +63,43 @@ def test_creates_both_files(self, builder: Builder, tmp_path: Path) -> None:
6063

6164
def test_regenerates_base_file(self, builder: Builder, tmp_path: Path) -> None:
6265
"""Test base file is always regenerated with new dependencies."""
63-
dependencies_v1 = [
66+
initial_dependencies = [
6467
ConanDependency(name='boost', version=ConanVersion.from_string('1.80.0')),
6568
]
6669

67-
builder.generate_conanfile(
68-
directory=tmp_path,
69-
dependencies=dependencies_v1,
70+
initial_data = ConanfileGenerationData(
71+
dependencies=initial_dependencies,
7072
dependency_groups={},
7173
name='test-project',
7274
version='1.0.0',
7375
)
76+
builder.generate_conanfile(
77+
directory=tmp_path,
78+
data=initial_data,
79+
)
7480

7581
base_file = tmp_path / 'conanfile_base.py'
76-
content_v1 = base_file.read_text(encoding='utf-8')
77-
assert 'boost/1.80.0' in content_v1
82+
initial_content = base_file.read_text(encoding='utf-8')
83+
assert 'boost/1.80.0' in initial_content
7884

79-
dependencies_v2 = [
85+
updated_dependencies = [
8086
ConanDependency(name='zlib', version=ConanVersion.from_string('1.2.13')),
8187
]
8288

83-
builder.generate_conanfile(
84-
directory=tmp_path,
85-
dependencies=dependencies_v2,
89+
updated_data = ConanfileGenerationData(
90+
dependencies=updated_dependencies,
8691
dependency_groups={},
8792
name='test-project',
8893
version='1.0.0',
8994
)
95+
builder.generate_conanfile(
96+
directory=tmp_path,
97+
data=updated_data,
98+
)
9099

91-
content_v2 = base_file.read_text(encoding='utf-8')
92-
assert 'zlib/1.2.13' in content_v2
93-
assert 'boost/1.80.0' not in content_v2
100+
updated_content = base_file.read_text(encoding='utf-8')
101+
assert 'zlib/1.2.13' in updated_content
102+
assert 'boost/1.80.0' not in updated_content
94103

95104
def test_preserves_user_file(self, builder: Builder, tmp_path: Path) -> None:
96105
"""Test user conanfile is never modified once created."""
@@ -112,13 +121,16 @@ def requirements(self):
112121
ConanDependency(name='boost', version=ConanVersion.from_string('1.80.0')),
113122
]
114123

115-
builder.generate_conanfile(
116-
directory=tmp_path,
124+
data = ConanfileGenerationData(
117125
dependencies=dependencies,
118126
dependency_groups={},
119127
name='new-name',
120128
version='2.0.0',
121129
)
130+
builder.generate_conanfile(
131+
directory=tmp_path,
132+
data=data,
133+
)
122134

123135
final_content = conan_file.read_text()
124136
assert final_content == custom_content
@@ -137,13 +149,16 @@ def test_inheritance_chain(self, builder: Builder, tmp_path: Path) -> None:
137149
]
138150
}
139151

140-
builder.generate_conanfile(
141-
directory=tmp_path,
152+
data = ConanfileGenerationData(
142153
dependencies=dependencies,
143154
dependency_groups=dependency_groups,
144155
name='test-project',
145156
version='1.0.0',
146157
)
158+
builder.generate_conanfile(
159+
directory=tmp_path,
160+
data=data,
161+
)
147162

148163
base_content = (tmp_path / 'conanfile_base.py').read_text(encoding='utf-8')
149164
user_content = (tmp_path / 'conanfile.py').read_text(encoding='utf-8')

0 commit comments

Comments
 (0)