Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5011 more tests #5015

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ce927d3
Bugfix: Not loading .env when quiet
smac89 Mar 25, 2022
0fcaacb
Create 5010.bugfix.md
smac89 Mar 25, 2022
0788b01
Refactor test into a version that also check quiet mode, move to corr…
matteius Mar 26, 2022
3d23755
Revert "Safely pin setuptools to fix failing test."
matteius Mar 26, 2022
ec69972
Revert "Attempt to pin setuptools to fix failing test."
matteius Mar 26, 2022
7210504
restrict the setuptools version internal to pipenv
matteius Mar 26, 2022
9eecbcc
restrict the setuptools version internal to pipenv
matteius Mar 26, 2022
d736a1f
limit the CI's version of setuptools as well, and only run the one fa…
matteius Mar 26, 2022
65e490c
Further attempts at restricting setuptools.
matteius Mar 27, 2022
16b3e5d
Further attempts at restricting setuptools.
matteius Mar 27, 2022
b1c0166
Disallow using system pip for standalone pip and use the vendored pip.
matteius Mar 27, 2022
fcbfca5
Evaluate if the standalone pip zip is bringing in the new setuptools.
matteius Mar 27, 2022
461922c
Try to determine the version of setuptools installed at the time the …
matteius Mar 27, 2022
d4063a0
iterate
matteius Mar 27, 2022
d42ea6c
Another spot setuptools is unpinned.
matteius Mar 27, 2022
ddb40ae
Another spot setuptools is unpinned.
matteius Mar 27, 2022
41f8b69
Another spot setuptools is unpinned.
matteius Mar 27, 2022
d038f4f
Dont upgrade
matteius Mar 27, 2022
aba475a
new setuptools keeps sneaking into the install in the CI somehow
matteius Mar 27, 2022
d881159
new setuptools keeps sneaking into the install in the CI somehow
matteius Mar 27, 2022
4708193
new setuptools keeps sneaking into the install in the CI somehow
matteius Mar 27, 2022
4f3c92a
new setuptools keeps sneaking into the install in the CI somehow
matteius Mar 27, 2022
1b85a64
new setuptools keeps sneaking into the install in the CI somehow
matteius Mar 27, 2022
67d8e84
new setuptools keeps sneaking into the install in the CI somehow
matteius Mar 27, 2022
0d6dd4c
new setuptools keeps sneaking into the install in the CI somehow
matteius Mar 27, 2022
ddabec5
new setuptools keeps sneaking into the install in the CI somehow
matteius Mar 27, 2022
421bdca
new setuptools keeps sneaking into the install in the CI somehow, get…
matteius Mar 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env

This file was deleted.

9 changes: 5 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ jobs:

- name: Install latest pip, setuptools, wheel
run: |
python -m pip install --upgrade pip setuptools wheel --upgrade-strategy=eager
python -m pip install --upgrade pip wheel --upgrade-strategy=eager
python -m pip install "setuptools>=40.8.0<=60.10.0"
- name: Install dependencies
env:
PIPENV_DEFAULT_PYTHON_VERSION: ${{ matrix.python-version }}
Expand All @@ -70,8 +71,8 @@ jobs:
run: |
git submodule sync
git submodule update --init --recursive
python -m pip install -e . --upgrade
pipenv install --deploy --dev --python=${{ steps.python-path.outputs.path }}
python -m pip install -e .
pipenv sync --dev --python=${{ steps.python-path.outputs.path }}
- name: Run tests
env:
PIPENV_DEFAULT_PYTHON_VERSION: ${{ matrix.python-version }}
Expand All @@ -83,7 +84,7 @@ jobs:
PYTHONIOENCODING: "utf-8"
GIT_SSH_COMMAND: ssh -o StrictHostKeyChecking=accept-new -o CheckHostIP=no
run: |
pipenv run pytest -ra -n auto --fulltrace tests
pipenv run pytest -ra -n auto --fulltrace tests -k test_lock_nested_vcs_direct_url -sv

build:
name: Build Package
Expand Down
1 change: 1 addition & 0 deletions news/5010.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Environment variables were not being loaded when the `--quiet` flag was set
1 change: 1 addition & 0 deletions news/5011.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adds missing unit test coverage for recent bug fixes.
11 changes: 6 additions & 5 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ def load_dot_env(project, as_dict=False, quiet=False):
)
if as_dict:
return dotenv.dotenv_values(dotenv_file)
elif os.path.isfile(dotenv_file) and not quiet:
click.echo(
crayons.normal(fix_utf8("Loading .env environment variables..."), bold=True),
err=True,
)
elif os.path.isfile(dotenv_file):
if not quiet:
click.echo(
crayons.normal(fix_utf8("Loading .env environment variables..."), bold=True),
err=True,
)
dotenv.load_dotenv(dotenv_file, override=True)
project.s.initialize()

Expand Down
7 changes: 2 additions & 5 deletions pipenv/patched/notpip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pipenv.patched.notpip._vendor.packaging.requirements import Requirement
from pipenv.patched.notpip._vendor.packaging.version import Version

from pip import __file__ as pip_location
from pipenv.patched.notpip import __file__ as pip_location
from pipenv.patched.notpip._internal.cli.spinners import open_spinner
from pipenv.patched.notpip._internal.locations import get_platlib, get_prefixed_libs, get_purelib
from pipenv.patched.notpip._internal.metadata import get_environment
Expand Down Expand Up @@ -203,10 +203,7 @@ def install_requirements(
# lacks importlib.resources and pep517 has issues loading files in
# a zip, so we fallback to the "old" method by adding the current
# pip directory to the child process's sys.path.
if sys.version_info < (3, 7):
pip_runnable = os.path.dirname(pip_location)
else:
pip_runnable = ctx.enter_context(_create_standalone_pip())
pip_runnable = os.path.dirname(pip_location)
self._install_requirements(
pip_runnable,
finder,
Expand Down
4 changes: 2 additions & 2 deletions pipenv/patched/notpip/_internal/pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def load_pyproject_toml(
# a version of setuptools that supports that backend.

build_system = {
"requires": ["setuptools>=40.8.0", "wheel"],
"requires": ["setuptools>=40.8.0<=60.10.0", "wheel"],
"build-backend": "setuptools.build_meta:__legacy__",
}

Expand Down Expand Up @@ -178,6 +178,6 @@ def load_pyproject_toml(
# tools themselves. The original PEP 518 code had a similar check (but
# implemented in a different way).
backend = "setuptools.build_meta:__legacy__"
check = ["setuptools>=40.8.0", "wheel"]
check = ["setuptools>=40.8.0<=60.10.0", "wheel"]

return BuildSystemDetails(requires, backend, check, backend_path)
2 changes: 1 addition & 1 deletion pipenv/patched/notpip/_vendor/pep517/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def compat_system(source_dir):
'build-backend',
'setuptools.build_meta:__legacy__',
)
system.setdefault('requires', ['setuptools', 'wheel'])
system.setdefault('requires', ['setuptools>=40.8.0<=60.10.0', 'wheel'])
return system


Expand Down
6 changes: 3 additions & 3 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def __init__(self, python_version=None, chdir=True):
self._original_dir = os.path.abspath(os.curdir)
self._environment = None
self._build_system = {
"requires": ["setuptools", "wheel"]
"requires": ["setuptools>=40.8.0<=60.10.0", "wheel"]
}
self.python_version = python_version
self.s = Setting()
Expand Down Expand Up @@ -559,15 +559,15 @@ def _read_pyproject(self):
if not os.path.exists(self.path_to("setup.py")):
if not build_system or not build_system.get("requires"):
build_system = {
"requires": ["setuptools>=40.8.0", "wheel"],
"requires": ["setuptools>=40.8.0<=60.10.0", "wheel"],
"build-backend": get_default_pyproject_backend(),
}
self._build_system = build_system

@property
def build_requires(self):
# type: () -> List[str]
return self._build_system.get("requires", ["setuptools>=40.8.0", "wheel"])
return self._build_system.get("requires", ["setuptools>=40.8.0<=60.10.0", "wheel"])

@property
def build_backend(self):
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/requirementslib/models/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def pyproject_backend(self):
setup_dict = SetupInfo.get_setup_cfg(self.setup_cfg)
pyproject_backend = get_default_pyproject_backend()
pyproject_requires = setup_dict.get(
"build_requires", ["setuptools", "wheel"]
"build_requires", ["setuptools>=40.8.0<=60.10.0", "wheel"]
) # type: ignore
if pyproject_requires:
self._pyproject_requires = tuple(pyproject_requires)
Expand Down
6 changes: 3 additions & 3 deletions pipenv/vendor/requirementslib/models/setup_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ def build_wheel(self):
need_delete = False
if not self.pyproject.exists():
if not self.build_requires:
build_requires = '"setuptools", "wheel"'
build_requires = '"setuptools>=40.8.0<=60.10.0", "wheel"'
else:
build_requires = ", ".join(
['"{0}"'.format(r) for r in self.build_requires]
Expand Down Expand Up @@ -1246,7 +1246,7 @@ def build_sdist(self):
need_delete = False
if not self.pyproject.exists():
if not self.build_requires:
build_requires = '"setuptools", "wheel"'
build_requires = '"setuptools>=40.8.0<=60.10.0", "wheel"'
else:
build_requires = ", ".join(
['"{0}"'.format(r) for r in self.build_requires]
Expand Down Expand Up @@ -1407,7 +1407,7 @@ def run_pyproject(self):
if requires:
self.build_requires = tuple(set(requires) | set(self.build_requires))
else:
self.build_requires = ("setuptools", "wheel")
self.build_requires = ("setuptools>=40.8.0<=60.10.0", "wheel")
return self

def get_initial_info(self):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools", "wheel"]
requires = ["setuptools>=40.8.0<=60.10.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"certifi",
"setuptools>=36.2.1,<61.0.0",
"virtualenv-clone>=0.2.5",
"virtualenv"
"virtualenv<20.14.0"
]
extras = {
"dev": [
Expand Down
21 changes: 0 additions & 21 deletions tests/integration/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,27 +210,6 @@ def test_scripts(PipenvInstance):
assert 'which python' in c.stdout


@pytest.mark.cli
def test_scripts_resolve_dot_env_vars(PipenvInstance):
with PipenvInstance() as p:
with open(".env", "w") as f:
contents = """
HELLO=WORLD
""".strip()
f.write(contents)

with open(p.pipfile_path, "w") as f:
contents = """
[scripts]
hello = "echo $HELLO"
""".strip()
f.write(contents)
c = p.pipenv('run hello')
print(c)
print(c.stdout)
assert 'WORLD' in c.stdout


@pytest.mark.cli
def test_help(PipenvInstance):
with PipenvInstance() as p:
Expand Down
37 changes: 37 additions & 0 deletions tests/integration/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,3 +804,40 @@ def test_default_lock_overwrite_dev_lock(PipenvInstance):
assert c.returncode == 0
assert p.lockfile["default"]["click"]["version"] == "==6.7"
assert p.lockfile["develop"]["click"]["version"] == "==6.7"


@flaky
@pytest.mark.lock
@pytest.mark.install
@pytest.mark.needs_internet
def test_pipenv_respects_package_index_restrictions(PipenvInstance):
with PipenvInstance() as p:
with open(p.pipfile_path, 'w') as f:
contents = """
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[[source]]
url = "{url}/simple"
verify_ssl = true
name = "local"

[packages]
requests = {requirement}
""".strip().format(url=p.pypi, requirement='{version="*", index="local"}')
f.write(contents)

c = p.pipenv('lock')
assert c.returncode == 0
assert 'requests' in p.lockfile['default']
assert 'idna' in p.lockfile['default']
assert 'certifi' in p.lockfile['default']
assert 'urllib3' in p.lockfile['default']
assert 'chardet' in p.lockfile['default']
# this is the newest version we have in our private pypi (but pypi.org has 2.27.1 at present)
expected_result = {'hashes': ['sha256:63b52e3c866428a224f97cab011de738c36aec0185aa91cfacd418b5d58911d1',
'sha256:ec22d826a36ed72a7358ff3fe56cbd4ba69dd7a6718ffd450ff0e9df7a47ce6a'],
'index': 'local', 'version': '==2.19.1'}
assert p.lockfile['default']['requests'] == expected_result
45 changes: 45 additions & 0 deletions tests/integration/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,48 @@ def test_run_with_usr_env_shebang(PipenvInstance):
project = Project()
lines = [line.strip() for line in c.stdout.splitlines()]
assert all(line == project.virtualenv_location for line in lines)


@pytest.mark.run
@pytest.mark.parametrize('quiet', [True, False])
def test_scripts_resolve_dot_env_vars(quiet, PipenvInstance):
with PipenvInstance() as p:
with open(".env", "w") as f:
contents = """
HELLO_VAR=WORLD
""".strip()
f.write(contents)

with open(p.pipfile_path, "w") as f:
contents = """
[scripts]
hello = "echo $HELLO_VAR"
""".strip()
f.write(contents)
if quiet:
c = p.pipenv('run --quiet hello')
else:
c = p.pipenv('run hello')
assert c.returncode == 0
assert 'WORLD\n' == c.stdout


@pytest.mark.run
@pytest.mark.parametrize('quiet', [True, False])
def test_pipenv_run_pip_freeze_has_expected_output(quiet, PipenvInstance):
with PipenvInstance() as p:
with open(p.pipfile_path, 'w') as f:
contents = """
[packages]
requests = "==2.14.0"
""".strip()
f.write(contents)
c = p.pipenv('install')
assert c.returncode == 0

if quiet:
c = p.pipenv('run --quiet pip freeze')
else:
c = p.pipenv('run pip freeze')
assert c.returncode == 0
assert 'requests==2.14.0\n' == c.stdout