Skip to content

Commit e78df43

Browse files
remove integration tests that mirror version inference integration unittests
1 parent 3bfe547 commit e78df43

File tree

1 file changed

+0
-210
lines changed

1 file changed

+0
-210
lines changed

testing/test_integration.py

Lines changed: 0 additions & 210 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import importlib.metadata
44
import logging
5-
import os
65
import re
76
import subprocess
87
import sys
@@ -72,219 +71,13 @@ def test_pyproject_support(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> N
7271
assert res.stdout == "12.34"
7372

7473

75-
PYPROJECT_FILES = {
76-
"setup.py": "[tool.setuptools_scm]\n",
77-
"setup.cfg": "[tool.setuptools_scm]\n",
78-
"pyproject tool.setuptools_scm": (
79-
"[project]\nname='setuptools_scm_example'\n[tool.setuptools_scm]"
80-
),
81-
"pyproject.project": (
82-
"[project]\nname='setuptools_scm_example'\n"
83-
"dynamic=['version']\n[tool.setuptools_scm]"
84-
),
85-
}
86-
87-
SETUP_PY_PLAIN = "__import__('setuptools').setup()"
88-
SETUP_PY_WITH_NAME = "__import__('setuptools').setup(name='setuptools_scm_example')"
89-
90-
SETUP_PY_FILES = {
91-
"setup.py": SETUP_PY_WITH_NAME,
92-
"setup.cfg": SETUP_PY_PLAIN,
93-
"pyproject tool.setuptools_scm": SETUP_PY_PLAIN,
94-
"pyproject.project": SETUP_PY_PLAIN,
95-
}
96-
97-
SETUP_CFG_FILES = {
98-
"setup.py": "",
99-
"setup.cfg": "[metadata]\nname=setuptools_scm_example",
100-
"pyproject tool.setuptools_scm": "",
101-
"pyproject.project": "",
102-
}
103-
104-
with_metadata_in = pytest.mark.parametrize(
105-
"metadata_in",
106-
["setup.py", "setup.cfg", "pyproject tool.setuptools_scm", "pyproject.project"],
107-
)
108-
109-
110-
@with_metadata_in
111-
def test_pyproject_support_with_git(wd: WorkDir, metadata_in: str) -> None:
112-
if sys.version_info < (3, 11):
113-
pytest.importorskip("tomli")
114-
115-
# Write files first
116-
if metadata_in == "pyproject tool.setuptools_scm":
117-
wd.write(
118-
"pyproject.toml",
119-
textwrap.dedent(
120-
"""
121-
[build-system]
122-
requires = ["setuptools>=80", "setuptools-scm>=8"]
123-
build-backend = "setuptools.build_meta"
124-
125-
[tool.setuptools_scm]
126-
dist_name='setuptools_scm_example'
127-
"""
128-
),
129-
)
130-
elif metadata_in == "pyproject.project":
131-
wd.write(
132-
"pyproject.toml",
133-
textwrap.dedent(
134-
"""
135-
[build-system]
136-
requires = ["setuptools>=80", "setuptools-scm>=8"]
137-
build-backend = "setuptools.build_meta"
138-
139-
[project]
140-
name='setuptools_scm_example'
141-
dynamic=['version']
142-
[tool.setuptools_scm]
143-
"""
144-
),
145-
)
146-
else:
147-
# For "setup.py" and "setup.cfg" cases, use the PYPROJECT_FILES content
148-
wd.write("pyproject.toml", PYPROJECT_FILES[metadata_in])
149-
150-
wd.write("setup.py", SETUP_PY_FILES[metadata_in])
151-
wd.write("setup.cfg", SETUP_CFG_FILES[metadata_in])
152-
153-
# Now do git operations
154-
wd("git init")
155-
wd("git config user.email [email protected]")
156-
wd('git config user.name "a test"')
157-
wd("git add .")
158-
wd('git commit -m "initial"')
159-
wd("git tag v1.0.0")
160-
161-
res = run([sys.executable, "setup.py", "--version"], wd.cwd)
162-
assert res.stdout == "1.0.0"
163-
164-
165-
def test_pyproject_no_project_section_no_auto_activation(wd: WorkDir) -> None:
166-
"""Test that setuptools_scm doesn't auto-activate when pyproject.toml has no project section."""
167-
if sys.version_info < (3, 11):
168-
pytest.importorskip("tomli")
169-
170-
# Create pyproject.toml with setuptools-scm in build-system.requires but no project section
171-
wd.write(
172-
"pyproject.toml",
173-
textwrap.dedent(
174-
"""
175-
[build-system]
176-
requires = ["setuptools>=80", "setuptools-scm>=8"]
177-
build-backend = "setuptools.build_meta"
178-
"""
179-
),
180-
)
181-
182-
wd.write("setup.py", "__import__('setuptools').setup(name='test_package')")
183-
184-
# Now do git operations
185-
wd("git init")
186-
wd("git config user.email [email protected]")
187-
wd('git config user.name "a test"')
188-
wd("git add .")
189-
wd('git commit -m "initial"')
190-
wd("git tag v1.0.0")
191-
192-
# Should not auto-activate setuptools_scm, so version should be None
193-
res = run([sys.executable, "setup.py", "--version"], wd.cwd)
194-
print(f"Version output: {res.stdout!r}")
195-
# The version should not be from setuptools_scm (which would be 1.0.0 from git tag)
196-
# but should be the default setuptools version (0.0.0)
197-
assert res.stdout == "0.0.0" # Default version when no version is set
198-
199-
200-
def test_pyproject_no_project_section_no_error(wd: WorkDir) -> None:
201-
"""Test that setuptools_scm doesn't raise an error when there's no project section."""
202-
if sys.version_info < (3, 11):
203-
pytest.importorskip("tomli")
204-
205-
# Create pyproject.toml with setuptools-scm in build-system.requires but no project section
206-
wd.write(
207-
"pyproject.toml",
208-
textwrap.dedent(
209-
"""
210-
[build-system]
211-
requires = ["setuptools>=80", "setuptools-scm>=8"]
212-
build-backend = "setuptools.build_meta"
213-
"""
214-
),
215-
)
216-
217-
# This should NOT raise an error because there's no project section
218-
# setuptools_scm should simply not auto-activate
219-
from setuptools_scm._integration.pyproject_reading import read_pyproject
220-
221-
pyproject_data = read_pyproject(wd.cwd / "pyproject.toml")
222-
# Should not auto-activate when no project section exists
223-
assert not pyproject_data.is_required or not pyproject_data.section_present
224-
225-
226-
@pytest.mark.parametrize("use_scm_version", ["True", "{}", "lambda: {}"])
227-
def test_pyproject_missing_setup_hook_works(wd: WorkDir, use_scm_version: str) -> None:
228-
wd.write(
229-
"setup.py",
230-
f"""__import__('setuptools').setup(
231-
name="example-scm-unique",
232-
use_scm_version={use_scm_version},
233-
)""",
234-
)
235-
wd.write(
236-
"pyproject.toml",
237-
textwrap.dedent(
238-
"""
239-
[build-system]
240-
requires=["setuptools", "setuptools_scm"]
241-
build-backend = "setuptools.build_meta"
242-
[tool.setuptools_scm]
243-
"""
244-
),
245-
)
246-
247-
res = subprocess.run(
248-
[sys.executable, "setup.py", "--version"],
249-
cwd=wd.cwd,
250-
check=True,
251-
stdout=subprocess.PIPE,
252-
encoding="utf-8",
253-
)
254-
stripped = res.stdout.strip()
255-
assert stripped.endswith("0.1.dev0+d20090213")
256-
257-
res_build = subprocess.run(
258-
[sys.executable, "-m", "build", "-nxw"],
259-
env={k: v for k, v in os.environ.items() if k != "SETUPTOOLS_SCM_DEBUG"},
260-
cwd=wd.cwd,
261-
)
262-
import pprint
263-
264-
pprint.pprint(res_build)
265-
wheel: Path = next(wd.cwd.joinpath("dist").iterdir())
266-
assert "0.1.dev0+d20090213" in str(wheel)
267-
268-
26974
def test_pretend_version(monkeypatch: pytest.MonkeyPatch, wd: WorkDir) -> None:
27075
monkeypatch.setenv(PRETEND_KEY, "1.0.0")
27176

27277
assert wd.get_version() == "1.0.0"
27378
assert wd.get_version(dist_name="ignored") == "1.0.0"
27479

27580

276-
@with_metadata_in
277-
def test_pretend_version_named_pyproject_integration(
278-
monkeypatch: pytest.MonkeyPatch, wd: WorkDir, metadata_in: str
279-
) -> None:
280-
test_pyproject_support_with_git(wd, metadata_in)
281-
monkeypatch.setenv(
282-
PRETEND_KEY_NAMED.format(name="setuptools_scm_example".upper()), "3.2.1"
283-
)
284-
res = wd([sys.executable, "setup.py", "--version"])
285-
assert res.endswith("3.2.1")
286-
287-
28881
def test_pretend_version_named(monkeypatch: pytest.MonkeyPatch, wd: WorkDir) -> None:
28982
monkeypatch.setenv(PRETEND_KEY_NAMED.format(name="test".upper()), "1.0.0")
29083
monkeypatch.setenv(PRETEND_KEY_NAMED.format(name="test2".upper()), "2.0.0")
@@ -305,7 +98,6 @@ def test_pretend_version_rejects_invalid_string(
30598
) -> None:
30699
"""Test that invalid pretend versions raise errors and bubble up."""
307100
monkeypatch.setenv(PRETEND_KEY, "dummy")
308-
wd.write("setup.py", SETUP_PY_PLAIN)
309101

310102
# With strict validation, invalid pretend versions should raise errors
311103
with pytest.raises(Exception, match=r".*dummy.*"):
@@ -325,7 +117,6 @@ def test_pretend_metadata_with_version(
325117
assert version == "1.2.3.dev4+g1337beef"
326118

327119
# Test version file template functionality
328-
wd.write("setup.py", SETUP_PY_PLAIN)
329120
wd("mkdir -p src")
330121
version_file_content = """
331122
version = '{version}'
@@ -402,7 +193,6 @@ def test_pretend_metadata_with_scm_version(
402193
assert "1.0.1.dev7+gcustom123" == version
403194

404195
# Test version file to see if metadata was applied
405-
wd.write("setup.py", SETUP_PY_PLAIN)
406196
wd("mkdir -p src")
407197
version_file_content = """
408198
version = '{version}'

0 commit comments

Comments
 (0)