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

125 commits

Author SHA1 Message Date
Jon Dufresne
72937f6520 Complete type annotations for tests/conftest.py and tests/lib/* 2021-09-29 19:57:29 -07:00
Jon Dufresne
943af79f26 Run mypy on the tests directory
The tests are a large consumer of the pip API (both the internal API and
otherwise). By running mypy on tests, we help to:

1. Ensure the internal API is consistent with regards to typing

2. Ensure the tests are representative of real life scenarios as the API
   are used correctly.

3. Helps to recognize unnecessary tests that simply pass junk data to
   functions which can be caught by the type checker.

4. Make sure test support code in tests/lib/ is correct and consistent.
   This is especially important when refactoring such code. For example, if
   we were to replace tests/lib/path.py with pathlib.

As a first start, untyped defs are allowed. All existing typing issues
have been resolved. Overtime, we can chip away at untyped defs and
eventually remove the configuration option for stricter type checking of
tests.

The following changes were made to help make mypy pass:

Remove unused record_callback argument from make_wheel() in tests.
Unused since its introduction in
6d8a58f7e1.

Replace toml with tomli_w in tests/functional/test_pep517.py. Unlike the
toml package, tomli_w contains inline typing annotations.

Remove unnecessary make_no_network_finder(). Unnecessary since
bab1e4f8a1 where the _get_pages method was
removed.
2021-08-22 09:57:26 -06:00
Tzu-ping Chung
e483f533fa Switch install scheme backend to sysconfig
This is only done for Python 3.10+ so we don't disrupt too many existing
pip installations.
2021-08-21 00:53:59 +08: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
55b12ba23a
Blacken conftest.py 2021-04-02 10:22:08 +01: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
d9b5525193 Prefer stdlib contextlib over contextlib2 when available
Removes the vendored contextlib2.

ExitStack and suppress are available from stdlib contextlib on all
supported Python versions.

The nullcontext context manager which isn't available in Python 3.6, but
the function is simple to implement. Once Python 3.6 support is dropped,
so too can the compat shim.
2021-02-19 04:13:33 -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
7f997c4b7f
Merge pull request #9373 from hugovk/tmpdir_remove 2021-02-18 21:39:07 +08:00
Andrey Bienkowski
9b2cb894ba Convert more str.format() calls to f-strings 2021-02-13 09:27:17 +03:00
Andrey Bienkowski
08bc2ab7f9 Add reminders to revert python3.7 compat fixes 2021-02-11 09:48:14 +03:00
Andrey Bienkowski
8db690e8a0 Fix MockServer not working right on python<3.8 2021-02-10 21:59:30 +03:00
Andrey Bienkowski
50db373adb Lint 2021-02-10 13:38:21 +03:00
Andrey Bienkowski
ab35018c04 Use unittest.mock instead of mock 2021-02-10 13:28:55 +03:00
Hugo van Kemenade
1ff092486b Replace Python 2 tmpdir removal workarounds 2020-12-27 17:34:57 +02:00
Pradyun Gedam
86afa89043
Merge pull request #9361 from jdufresne/f-strings
Use f-strings for simple string formatting
2020-12-26 10:24:18 +00:00
Jon Dufresne
cdcf74fb8e Use f-strings for simple string formatting
Use pyupgrade to convert simple string formatting to use f-string
syntax. pyupgrade is intentionally timid and will not create an f-string
if it would make the expression longer or if the substitution parameters
are anything but simple names or dotted names.
2020-12-25 16:21:20 -08:00
Jon Dufresne
09b3d3a50b Remove object from class definitions
Unnecessary since dropping Python 2 support. In Python 3, all classes
are new style classes.
2020-12-25 15:48:11 -08:00
Jon Dufresne
2e38024991 Drop u prefix from str literals
Unnecessary since dropping Python 2 support.

This makes one test case from test_str_to_display a duplicate and so has
been removed.
2020-12-25 07:26:06 -08:00
Hugo van Kemenade
817ee23051 Remove redundant Python 2.7 code 2020-12-22 09:06:26 +02:00
Pradyun Gedam
79f1b59335
We have no deprecated versions of Python now 2020-12-19 19:55:09 +00:00
Tzu-ping Chung
145be2eaf2 Skip pip search tests unless explicitly requested 2020-12-15 17:23:20 +08:00
Pradyun Gedam
6f26fb9fee
Update tests for resolver changes 2020-10-30 23:08:31 +05:30
Pradyun Gedam
6859de08d9
Get the resolver name directly from test CLI 2020-10-30 07:16:25 +05:30
Pradyun Gedam
07ec3013f0
Drop custom logic for new_resolver tests 2020-10-30 07:16:19 +05:30
Pradyun Gedam
5cba61e118
Switch to resolver variants in the test suite 2020-10-30 07:16:19 +05:30
Pradyun Gedam
66bb8a88c4
Add a small delay between re-runs 2020-10-25 23:03:10 +05:30
Pradyun Gedam
9faf431fbb
Breakup conditional for readability 2020-10-25 23:02:59 +05:30
Pradyun Gedam
25ab172b55
Update linter: isort 2020-09-23 19:52:28 +05:30
Xavier Fernandez
822d42b11a
Merge pull request #8614 from McSinyx/monkeypatch.setenv
Use monkeypatch.setenv to mock env vars
2020-09-04 11:05:15 +02:00
4a2e03c4ff Use monkeypatch for env var in wheel unit tests 2020-09-04 15:06:08 +07:00
cd549eb7f1 Use mock to patch for TZ env var 2020-09-04 15:06:08 +07:00
Hugo
e93257c080 Warn Python 3.5 support is deprecated and will be removed in pip 21.0, Jan 2021 2020-08-18 15:22:16 +03:00
5b1093fc75 Use monkeypatch.*env in conftest and tests.lib
Session fixtures have to use mock.patch.dict though
2020-07-25 20:46:45 +07:00
Chris Hunt
cb540f30e3 Add basic test coverage configuration
This handles:

* Sub-processes within unit tests (thanks pytest-cov)
* Our pytest-fixture-based virtual environments and subprocesses
  therein
* Running with xdist (e.g. `-n auto`)
* Combining results from all of the above using paths rooted with
  `src/pip/*`

This doesn't handle:

* Platform-specific branches
* Python 2
* CI integration
2020-07-07 21:58:55 -04:00
Pradyun Gedam
49b793cd03
Set correct envvar for new-resolver tests 2020-07-03 20:11:36 +05:30
Sumana Harihareswara
cef69fef7f Updated author email in configuration and tests
Per https://groups.google.com/d/msg/pypa-dev/rUNsfIbruHM/LCEx-CB5AgAJ
the pypa-dev Google Group is now decommissioned.
Using distutils-sig instead as author/maintainer email.

Signed-off-by: Sumana Harihareswara <sh@changeset.nyc>
2020-05-28 16:51:02 -04:00
Paul Moore
c2fa0dd997 Add a mark for tests that fail on the new resolver 2020-05-21 15:39:00 +01:00
Tzu-ping Chung
a82a5e7abe Add pytest option to globally switch resolver 2020-05-14 18:00:42 +08:00
Ilan Schnell
6db7f42186 sort imports 2020-03-31 01:42:40 -05:00
Ilan Schnell
2c6a063a27 remove proxy module tests/lib/scripttest.py in favour of importing from tests.lib directly 2020-03-31 01:25:45 -05:00
Jason R. Coombs
6282a307dc 👹 Feed the hobgoblins (delint). 2020-03-06 12:43:10 -05:00
Jason R. Coombs
3511d3d493 Convert the remaining '%' formatters to '.format'. Fixes #6973. 2020-03-06 12:43:03 -05:00
Chris Hunt
f2af7df453 Use tempdir_registry to control auto-deleted files globally
Next we can actually transition some files to be globally-managed that
are only deleted conditionally.
2020-01-29 23:04:26 -05:00
Tzu-ping Chung
facf5c8894 Add comments to unicode workarounds 2020-01-09 13:11:30 +05:30
Tzu-ping Chung
37f97140af Also use rmtree to remove tmpdir_factory
Same as e2c3451001
2020-01-09 13:00:49 +05:30
Tzu-ping Chung
e2c3451001 Delete tmpdir with rmtree to handle Unicode paths
pytest (rather py.path.local) does not handle non-ASCII paths properly
on Windows with Python 2, but Python's builtin shutil.rmtree() does.

Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
2020-01-08 18:26:42 +05:30
Chris Hunt
82a2651f93 Move pip._internal.main to cli submodule
Moving this out of the way gives us the flexibility to define wrappers
that will redirect requests to our old entrypoints to our new one.
2019-12-18 21:09:22 -05:00
Chris Hunt
6343e8093f Replace atexit with globally-managed tempdir 2019-12-09 06:06:37 +08:00