Skip to content

Commit c96e2f9

Browse files
committed
Create a test case for define-macros in pyproject.toml
1 parent fb7f3d3 commit c96e2f9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

setuptools/tests/config/test_apply_pyprojecttoml.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,27 @@ def test_pyproject_sets_attribute(self, tmp_path, monkeypatch):
345345
assert dist.ext_modules[0].name == "my.ext"
346346
assert set(dist.ext_modules[0].sources) == {"hello.c", "world.c"}
347347

348+
def test_pyproject_sets_define_macros(self, tmp_path, monkeypatch):
349+
monkeypatch.chdir(tmp_path)
350+
pyproject = Path("pyproject.toml")
351+
toml_config = """
352+
[project]
353+
name = "test"
354+
version = "42.0"
355+
[tool.setuptools]
356+
ext-modules = [
357+
{name = "my.ext", sources = ["hello.c", "world.c"], define-macros = [ ["FIRST_MACRO_SINGLE_ELEMENT"], ["SECOND_MACRO_TWO_ELEMENT", "1"]]}
358+
]
359+
"""
360+
pyproject.write_text(cleandoc(toml_config), encoding="utf-8")
361+
with pytest.warns(pyprojecttoml._ExperimentalConfiguration):
362+
dist = pyprojecttoml.apply_configuration(Distribution({}), pyproject)
363+
assert len(dist.ext_modules) == 1
364+
assert dist.ext_modules[0].name == "my.ext"
365+
assert set(dist.ext_modules[0].sources) == {"hello.c", "world.c"}
366+
assert dist.ext_modules[0].define_macros[0] == tuple("FIRST_MACRO_SINGLE_ELEMENT")
367+
assert dist.ext_modules[0].define_macros[1] == ("SECOND_MACRO_TWO_ELEMENT", "1")
368+
348369

349370
class TestDeprecatedFields:
350371
def test_namespace_packages(self, tmp_path):

0 commit comments

Comments
 (0)