Skip to content

Commit f2d2bc7

Browse files
authored
Improve package manager tests (#1754)
Backports a number of updates/improvements to the pip/Poetry/Pipenv package manager integration tests found while working on the tests for uv.
1 parent ee0a9eb commit f2d2bc7

File tree

12 files changed

+98
-52
lines changed

12 files changed

+98
-52
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# Note: This test has to use Python 3.12 until we work around the
2+
# Pipenv editable VCS dependency cache invalidation bug.
13
3.12

spec/fixtures/pipenv_editable/Pipfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7+
gunicorn = {git = "git+https://github.com/benoitc/gunicorn", ref = "20.1.0", editable = true}
78
local-package-pyproject-toml = {file = "packages/local_package_pyproject_toml", editable = true}
89
local-package-setup-py = {file = "packages/local_package_setup_py", editable = true}
9-
gunicorn = {git = "git+https://github.com/benoitc/gunicorn", ref = "20.1.0", editable = true}
10+
pipenv-editable = {file = ".", editable = true}

spec/fixtures/pipenv_editable/Pipfile.lock

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/pipenv_editable/pipenv_editable/__init__.py

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[project]
2+
name = "pipenv-editable"
3+
version = "0.0.0"
4+
requires-python = ">=3.12"
5+
6+
[build-system]
7+
requires = ["hatchling"]
8+
build-backend = "hatchling.build"

spec/fixtures/poetry_editable/bin/test-entrypoints.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44

55
cd .heroku/python/lib/python*/site-packages/
66

7-
# List any path like strings in .pth, and finder files in site-packages.
7+
# List any path like strings in the .pth and finder files in site-packages.
88
grep --extended-regexp --only-matching -- '/\S+' *.pth __editable___*_finder.py | sort
99
echo
1010

spec/fixtures/poetry_editable/poetry.lock

Lines changed: 21 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/poetry_editable/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = []
66

77
[tool.poetry.dependencies]
88
python = "^3.13"
9-
gunicorn = { git = "https://github.com/benoitc/gunicorn.git", tag = "20.1.0", develop = true }
9+
gunicorn = { git = "https://github.com/benoitc/gunicorn.git", develop = true }
1010
local-package-pyproject-toml = { path = "packages/local_package_pyproject_toml", develop = true }
1111
local-package-setup-py = { path = "packages/local_package_setup_py", develop = true }
1212

spec/hatchet/ci_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
it 'installs both normal and test dependencies and uses cache on subsequent runs' do
1212
app.run_ci do |test_run|
13-
expect(test_run.output).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE))
13+
expect(clean_output(test_run.output)).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE))
1414
-----> Python app detected
1515
-----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
1616
-----> Installing Python #{DEFAULT_PYTHON_FULL_VERSION}
@@ -62,7 +62,7 @@
6262
REGEX
6363

6464
test_run.run_again
65-
expect(test_run.output).to include(<<~OUTPUT)
65+
expect(clean_output(test_run.output)).to include(<<~OUTPUT)
6666
-----> Python app detected
6767
-----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
6868
-----> Restoring cache
@@ -81,7 +81,7 @@
8181

8282
it 'installs both normal and test dependencies and uses cache on subsequent runs' do
8383
app.run_ci do |test_run|
84-
expect(test_run.output).to match(Regexp.new(<<~REGEX))
84+
expect(clean_output(test_run.output)).to match(Regexp.new(<<~REGEX))
8585
-----> Python app detected
8686
-----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
8787
-----> Installing Python #{DEFAULT_PYTHON_FULL_VERSION}
@@ -134,7 +134,7 @@
134134
REGEX
135135

136136
test_run.run_again
137-
expect(test_run.output).to match(Regexp.new(<<~REGEX))
137+
expect(clean_output(test_run.output)).to match(Regexp.new(<<~REGEX))
138138
-----> Python app detected
139139
-----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
140140
-----> Restoring cache
@@ -156,7 +156,7 @@
156156

157157
it 'installs both normal and test dependencies and uses cache on subsequent runs' do
158158
app.run_ci do |test_run|
159-
expect(test_run.output).to match(Regexp.new(<<~REGEX))
159+
expect(clean_output(test_run.output)).to match(Regexp.new(<<~REGEX))
160160
-----> Python app detected
161161
-----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
162162
-----> Installing Python #{DEFAULT_PYTHON_FULL_VERSION}
@@ -217,7 +217,7 @@
217217
REGEX
218218

219219
test_run.run_again
220-
expect(test_run.output).to include(<<~OUTPUT)
220+
expect(clean_output(test_run.output)).to include(<<~OUTPUT)
221221
-----> Python app detected
222222
-----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
223223
-----> Restoring cache

spec/hatchet/pip_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@
9191
end
9292

9393
# This test intentionally uses Python 3.12, so that we test rewriting using older globally installed
94-
# setuptools. The Poetry equivalent of this test covers the PEP-517/518 setuptools case.
94+
# setuptools (which causes .egg-link files to be created too). The Pipenv and Poetry equivalents of
95+
# this test covers the PEP-517/518 setuptools case.
9596
context 'when requirements.txt contains editable requirements (both VCS and local package)' do
9697
let(:buildpacks) { [:default, 'heroku-community/inline'] }
9798
let(:app) { Hatchet::Runner.new('spec/fixtures/pip_editable', buildpacks:) }
@@ -159,6 +160,8 @@
159160
remote: Running entrypoint for the setup.py-based local package: Hello setup.py!
160161
remote: Running entrypoint for the VCS package: gunicorn \\(version 20.1.0\\)
161162
REGEX
163+
# Test that the VCS repo checkout was cached correctly.
164+
expect(app.output).to include('Updating /app/.heroku/python/src/gunicorn clone (to revision 20.1.0)')
162165
end
163166
end
164167
end

0 commit comments

Comments
 (0)