1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00
Commit graph

210 commits

Author SHA1 Message Date
Tzu-ping Chung
2fad07e6e2 Merge branch 'main' into no-import-from-conftest 2023-10-03 16:11:30 +08:00
hauntsaninja
666be3544b Avoid use of 2020-resolver and legacy-resolver 2023-09-23 13:34:06 -07:00
Shantanu
eddd9ddb66
Enable mypy's strict equality checks (#12209)
This makes mypy check more behaviours within the codebase.

Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
2023-09-23 17:10:13 +01:00
Christian Clauss
0a24a001fb Fix issues raised in code review 2023-08-28 15:04:54 +02:00
Christian Clauss
69a1e956da Ruff rules C4,C90,PERF 2023-08-28 14:51:13 +02:00
Shantanu
d8cd93f4fa
Fix incorrect use of re function in tests (#12213) 2023-08-08 07:37:38 -05:00
Paul Moore
7c3418b2d0
Add explicit ID to noqa comment
Co-authored-by: q0w <43147888+q0w@users.noreply.github.com>
2023-06-05 14:50:10 +01:00
Paul Moore
9824a426d4 Fix new lint errors 2023-06-05 14:32:44 +01:00
Tzu-ping Chung
c3160c5423 Avoid importing things from conftest
It is generally discouraged to import from conftest. Things are now
moved to tests.lib and imported from there instead.

Also did some cleanup to remove the no-longer-needed nullcontext shim.
2023-05-09 15:43:53 +08:00
Tzu-ping Chung
bfbe919fd2
Merge pull request #11277 from vanschelven/respect-no-index-from-requirements-file 2022-08-30 15:47:51 +08:00
hauntsaninja
edbfeae9fb fix tests 2022-08-12 19:01:26 -07:00
Stéphane Bidoul
58d8dc28cb
Do not fail tests on our own deprecation warnings 2022-08-05 09:35:00 +02:00
Stéphane Bidoul
b423c07ff4
Detected indented ERROR and WARNING messages in tests 2022-08-05 09:35:00 +02:00
Paul Moore
662f940c96 Merge branch 'main' into test_zipapp 2022-07-28 10:51:04 +01:00
Klaas van Schelven
5d7a1a68c7 Respect --no-index from the requirements file
See #11276

SearchScope was extended with an extra parameter to be able to pass-on the
value of no_index as we do with the other parameters. This allows us to respect
its value regardless of the order in which options are evaluated.
2022-07-20 15:55:17 +02:00
Stéphane Bidoul
bb2a3d7410
Remove the html5lib deprecated feature flag. 2022-07-16 19:37:11 +02:00
Paul Moore
c7e7e426cb Apply black 2022-07-12 09:02:11 +01:00
Paul Moore
ef999f4c76 Ignore temporary extracted copies of cacert.pem when testing with a zipapp 2022-07-11 17:18:21 +01:00
Paul Moore
a57668ef12 Add an option to the test suite to specify a zipapp to test 2022-07-11 16:26:24 +01:00
Stéphane Bidoul
25dd00571a
Merge pull request #11022 from SpecLad/download-propagate-pep517
pip download: make sure that --use-pep517 is propagated to the dependencies
2022-06-24 19:42:58 +02:00
q0w
c8c88ce520 Adapt tests 2022-06-23 19:20:18 +03:00
Роман Донченко
28d7730087 test_download_use_pep517_propagation: use a different approach
The approach it uses now doesn't work anymore due to 452d7da8.
The installation of `fake_dep` now succeeds whether or not `setuptools`
is installed in the test environment.

Use a different approach instead: try to import `pip` in the `setup.py`
script. If it succeeds, then we are not running in an isolated environment,
and therefore PEP 517 isn't being used.

To add this custom logic to `setup.py`, add a new argument to
`create_basic_sdist_for_package`. Note that to make this work, I had to
switch from f-strings to `str.format`, since the `dedent` has to happen
before formatting.
2022-06-15 18:11:07 +03:00
Роман Донченко
698784796b pip download: make sure that --use-pep517 is propagated to the dependencies 2022-06-15 18:10:22 +03:00
Tzu-ping Chung
42359a9605 Migrate tests to use pathlib.Path
The pip-specific Path implementation has been removed, and all its
usages replaced by pathlib.Path. The tmpdir and tmpdir_factory fixtures
are also removed, and all usages are replaced by tmp_path and
tmp_path_factory, which use pathlib.Path.

The pip() function now also accepts pathlib.Path so we don't need to put
str() everywhere. Path arguments are coerced with os.fspath() into str.
2022-06-08 19:58:46 +08:00
Pradyun Gedam
afda75625c
Present the result, when the script passes unexpectedly 2022-02-26 12:32:53 +00:00
Jon Dufresne
bf5f4008e7
Replace vendored html5lib with stdlib
The html5lib library isn't strictly required as the same functionality
can be achieved through the stdlib html.parser module.

The html5lib is one of the largest uses of the six library. By dropping
this unnecessary dependency, the pip project is closer to dropping the
six library.

Additionally, html5lib maintenance has slowed down and the project has
rejected pull requests to drop Python 2 support.

For now, the html5lib code remains, but is gated behind a command
line option: `--use-deprecated=html5lib`. After a sufficient amount of
time has passed without any reported bugs, the vendored library and this
flag can be removed completely.
2022-01-28 06:45:57 +00:00
Pradyun Gedam
8eeee22304
Abort immediately on metadata generation failure instead of backtracking
This behaviour is more forgiving when a source distribution cannot be
installed (eg: due to missing build dependencies or platform
incompatibility) and favours early eager failures instead of trying to
ensure that a package is installed regardless of the amount of effort it
takes.
2022-01-27 18:11:02 +00:00
Pradyun Gedam
ff8b9a167e
Mark TestPipResult as not having tests
This makes pytest stop warning about it.
2022-01-21 14:10:40 +00:00
Tzu-ping Chung
7d27b9c412 Fix various typing errors on Windows 2021-11-22 15:55:31 +08:00
Jon Dufresne
c71cf88049 Complete type annotations of tests/functional/ directory 2021-11-18 18:26:17 -08:00
Jon Dufresne
72937f6520 Complete type annotations for tests/conftest.py and tests/lib/* 2021-09-29 19:57:29 -07:00
Tzu-ping Chung
d91fecdb5a
Merge pull request #10436 from jdufresne/fixture-data
Set TestData.__test__ to False to avoid pytest discovery
2021-09-28 21:50:37 +08:00
Jon Dufresne
8b24a66aa1 Set TestData.__test__ to False to avoid pytest discovery
As the class name starts with "Test", pytest interprets it as a test
case, but it is not one. Further, due to its `__init__` method, pytest
emits the following warning:

    .../pip/tests/lib/__init__.py:141: PytestCollectionWarning: cannot
    collect test class 'TestData' because it has a __init__ constructor

For additional information on pytest discovery, see:
https://docs.pytest.org/en/latest/example/pythoncollection.html
2021-09-05 13:51:46 -07:00
Jon Dufresne
9e88e8708f Replace assert_raises_regexp function with pytest.raises
These methods serve the same purpose. Can shift to using the upstream
implementation.

https://docs.pytest.org/en/latest/reference/reference.html#pytest.raises
2021-08-29 07:09:50 -07:00
Jon Dufresne
d4a2f89fd1 Remove unused argument run_from from PipTestEnvironment.run() 2021-08-26 18:55:52 -07:00
Jon Dufresne
d144fd960c Cleanup several Python 2 version_info checks/workarounds 2021-08-20 09:39:31 -06:00
Jon Dufresne
6a6561c2cb Move many type comments to annotations
Use the tool com2ann to automatically convert most type comments to type
annotations. Some type comments continue to exist where any work beyond
the automatic conversion was required (for example, additional
formatting or circular references).

For additional information on the com2ann tool, see:
https://github.com/ilevkivskyi/com2ann
2021-08-10 07:12:32 -07:00
Pradyun Gedam
a196b3bf01
Minor formatting tweaks (#10190)
Co-authored-by: Pradyun Gedam <pradyunsg@users.noreply.github.com>
2021-07-24 03:55:14 +08:00
Tzu-ping Chung
e6c317769a Move assert_[not_]installed to Script and use it
This help function is much better than the previous ad-hoc logic used in
test_uninstall.py, which has trouble identifying normalized names.
2021-07-12 11:44:23 +08:00
Pradyun Gedam
37ad296684
Tweak textwrap.dedent strings 2021-04-02 12:00:01 +01:00
Pradyun Gedam
ebb80861ee
Blacken tests/lib 2021-04-02 11:59:57 +01:00
Andrey Bienkowski
e4e9af1d27 Drop python2 related stuff in tests 2021-02-23 13:49:59 +03:00
Pradyun Gedam
c2ba7c043b
Merge pull request #9606 from hexagonrecursion/fstr 2021-02-21 08:30:00 +00:00
Jon Dufresne
0945809afc Remove typing.TYPE_CHECKING guards
The typing module has been available since Python 3.5. Guarding the
import has been unnecessary since dropping Python 2.

Some guards remain to either:

- Avoid circular imports
- Importing objects that are also guarded by typing.TYPE_CHECKING
- Avoid mypy_extensions dependency
2021-02-19 18:34:21 -08:00
Jon Dufresne
a6392bd62e Replace pip._internal.utils.typing with stdlib typing
The stdlib module has been available since Python 3.5 and the
TYPE_CHECKING constant has been available since 3.5.2.

By using stdlib, this removes the need for pip to maintain its own
Python 2 typing compatibility shim.
2021-02-18 19:09:13 -08:00
Tzu-ping Chung
5fac450375
Merge pull request #9368 from jdufresne/ensure
Remove unnecessary uses of six.ensure_(binary|str|text)
2021-02-18 20:40:21 +08:00
Andrey Bienkowski
a9b8d12286
Apply review suggestion
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
2021-02-18 08:33:44 +00:00
Andrey Bienkowski
9b2cb894ba Convert more str.format() calls to f-strings 2021-02-13 09:27:17 +03:00
Jon Dufresne
8683413501 Use keyword-only arguments
https://www.python.org/dev/peps/pep-3102/

Replaces the pattern: self.name = kwargs.pop('name')

Keyword-only arguments offer some advantages:

- In the event of a typo or misuse, a more informative error is
  presented to the programmer.

- More self documenting and makes interfaces more explicit.

- They more easily allow explicit typing.

Adding types to ConfigOptionParser required changing some call sites to
pass arguments without using a dict due to mypy bug:
https://github.com/python/mypy/issues/9676
2021-01-29 21:15:36 -08:00
Jon Dufresne
c115cdc81a Remove unnecessary uses of six.ensure_(binary|str|text)
Now that Python 2 is not supported, the bytes/str boundaries are more
clear and explicit. Using six.ensure_* methods for backwards
compatibility is no longer necessary as the types are known and verified
using mypy.

One exception is tests/lib/wheel.py which allows tests to pass test
setup data as either bytes or str.

The module operations.install.wheel also remains untouched as it is
especially delicate to bytes/str mixups and the current version is
working.
2020-12-27 07:56:18 -08:00