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

180 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
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
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
Pradyun Gedam f91ba6b348
Merge pull request #9354 from jdufresne/super
Use short Python3 super() syntax
2020-12-25 19:18:28 +00: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
Jon Dufresne c148bcc1aa Use short Python3 super() syntax 2020-12-24 15:11:51 -08:00
Jon Dufresne f32adaf09b Remove __future__ imports
Unnecessary since dropping Python 2.
2020-12-24 08:38:09 -08:00
Hugo van Kemenade 9db97546b3 os.curdir is already a str
Co-authored-by: Jon Dufresne <jon.dufresne@gmail.com>
2020-12-22 22:41:58 +02:00
Hugo van Kemenade 817ee23051 Remove redundant Python 2.7 code 2020-12-22 09:06:26 +02:00
Pradyun Gedam 25ab172b55
Update linter: isort 2020-09-23 19:52:28 +05:30
Nguyễn Gia Phong 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
Devesh Kumar Singh db11f83e2a Fix tests module with flake8-bugbear 2020-06-05 02:41:08 +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
Pradyun Gedam 2552151858
Add helpers to TestPipResult 2020-05-22 17:27:44 +05:30
Paul Moore 80c640b5a8
Merge pull request #8067 from deveshks/fix-create-basic-wheel-bug
Canonicalise package name in tests.lib.create_basic_wheel_for_package
2020-05-21 13:54:01 +01:00
Ilan Schnell 28b0fd353b add allow_error parameter to .run() method 2020-04-28 22:49:18 -05:00
Devesh Kumar Singh 7bcccbd3dc Canonicalise package name in tests.lib.create_basic_wheel_for_package 2020-04-17 01:21:51 +05:30
Paul Moore 037791d170 Add a test demonstrating #7966 2020-04-03 11:18:44 +01:00
Tzu-ping Chung 22f7c883ad Requires-Python support in test helper 2020-04-02 18:38:43 +08:00
Tzu-ping Chung 09f4d0004b Use extra_files to write package files instead 2020-04-02 01:25:05 +08:00
Tzu-ping Chung 2c8a0bff42 Rewrite tests.lib.create_basic_wheel_for_package
This implementation uses tests.lib.make_wheel, which allows more
flexible wheel configuration in a more structured way.

Output-wise this should be almost identical to the previous
implementation, with the following exceptions:

* Metadata-Version is bumped from 2.0 (previous implementation) to 2.1
  (from make_wheel).
* Fields previously supplied as UNKNOWN are now omitted since they are
  not significant to tests.
* The DESCRIPTION file is omitted (since the description field is now
  missing, see previous point).
2020-03-30 03:20:00 +08:00
gutsytechster 315447d170 fix(tests/lib): Catch subprocess.CalledProcessError in need_executable
This fixes https://github.com/pypa/pip/issues/7924
2020-03-29 16:21:02 +05:30
Jason R. Coombs fd288ab0e5 Merge remote-tracking branch 'origin/master' into bugfix/6973-format-method 2020-03-06 18:17:10 -05:00
Jason R. Coombs 3511d3d493 Convert the remaining '%' formatters to '.format'. Fixes #6973. 2020-03-06 12:43:03 -05:00
Jason R. Coombs 2c0d691893 Skip svn tests if svnadmin is not available. Fixes #7823. 2020-03-06 04:09:48 -05:00
Chris Hunt dd8753cdee Mitigate Windows test failures due to PAX-format wheel release 2020-01-29 08:53:23 -05:00
Tzu-ping Chung facf5c8894 Add comments to unicode workarounds 2020-01-09 13:11:30 +05:30
Tzu-ping Chung 7a80acaf44 Tell shutil.make_archive to use Unicode paths
By default, make_archive uses str paths on Python 2, which causes it to
skip files with unencodable names. By passing in a unicode base_dir
explicitly, it is smart enough to use unicode all the way down instead.
2020-01-09 13:01:31 +05:30
Chris Hunt 33043ba22f Use pkg_resources.Distribution derived from wheel directly
We now extract all metadata files from the wheel directly into memory
and make them available to the wrapping pkg_resources.Distribution via
the DictMetadata introduced earlier.
2020-01-05 10:57:14 -05:00
Chris Hunt b58205ea01 Use valid wheel for functional download tests
Previously we were copying an existing wheel to a file with a
different distribution name. When using stricter metadata parsing this
would fail, so now we use a more conformant dummy wheel function.
2020-01-04 23:08:43 +01:00