Commit Graph

79 Commits

Author SHA1 Message Date
Chris Hunt 3f9b326c11 Provide a reasonable error on invalid scheme keys
Originally we would throw an `AttributeError` if a bad scheme key was
used. After refactoring we would throw a `KeyError`, which isn't much
better. Now we call out the wheel being processed, scheme key we didn't
recognize, and provide a list of the valid scheme keys. This would
likely be useful for people developing/testing the wheel.
2020-07-29 22:24:09 -04:00
Chris Hunt 864f0e0efa Explicitly handle incorrect .data paths during wheel install
Previously our wheel installation process allowed wheels which contained
non-conforming contents in a contained .data directory.

After the refactoring to enable direct-from-wheel installation, pip
throws an exception when encountering these wheels, but does not include
any helpful information to pinpoint the cause.

Now if we encounter such a wheel, we trace an error that includes the
name of the requirement we're trying to install, the path to the wheel
file, the path we didn't understand, and a hint about what we expect.
2020-07-29 18:12:16 -04:00
Stéphane Bidoul ccdfa74d79
Reduce reliance on .egg-info directories in test suite
Make more tests run with with_wheel and test
that a .dist-info directory is created.
2020-07-25 13:02:20 +02:00
Christopher Hunt 2f9b50c097
Merge pull request #8534 from chrahunt/thoroughly-test-header-installation
Make wheel header installation test more explicit
2020-07-08 17:21:47 -04:00
Chris Hunt ffddab6986 Test that RECORD is populated correctly for data files 2020-07-07 09:25:16 -04:00
Chris Hunt b5f02f9dd8 Check that expected text is written in include files
This is a little more specific than checking that we happened to create
an already-empty file, and is a better mirror for reality.
2020-07-04 14:23:10 -04:00
Chris Hunt 0b0d53e8fa Use wheel helper function instead of pre-created wheel file 2020-07-04 14:22:15 -04:00
Chris Hunt 00191b2db1 Explicitly test that header file was created as-expected
Since this is the special part of this test. This gives us more
confidence that we're doing the right thing when removing the standalone
wheel file next.
2020-07-04 14:22:15 -04:00
Tzu-ping Chung f81fd19a7b Ensure entry points are read as UTF-8
Like the wheel metadata, this is, strictly speaking, unspecified. But
UTF-8 is the de-facto standard, and we should support that.
2020-06-10 20:58:20 +08:00
gutsytechster ccee4c784c Refactor test 2020-05-28 16:32:07 +05:30
gutsytechster 41d33cc83c fix(test_install_wheels): Fix flake8 errors 2020-05-28 16:05:17 +05:30
gutsytechster fa280b9370 tests(test_install_{vcs_git, wheel}.py): Refactor path lookups 2020-05-28 15:48:16 +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
Tzu-ping Chung 1056681686 Non-ASCII names are not weird 2020-05-19 16:03:51 +08:00
Tzu-ping Chung dc4171c213 Python 2 works but not tested 2020-05-19 16:03:51 +08:00
Tzu-ping Chung 2339a7a859 Fix installation of wheel with non-ASCII entries
This mainly deals with correctly recording the wheel content in the
RECORD metadata. This metadata file must be written in UTF-8, but the
actual files need to be installed to the filesystem, the encoding of
which is not (always) UTF-8. So we need to carefully handle file name
encoding/decoding when comparing RECORD entries to the actual file.

The fix here makes sure we always use the correct encoding by adding
strict type hints. The entries in RECORD is decoded/encoded with UTF-8
on the read/write boundaries to make sure we always deal with text
types. A type-hint-only type RecordPath is introduced to make sure this
is enforced (because Python 2 "helpfully" coerces str to unicode with
the wrong encoding).
2020-05-19 16:03:51 +08:00
Devesh Kumar Singh 22878a827b Added unit tests to verify correct normalization of package name 2020-04-18 11:03:56 +05:30
Chris Hunt 667dc392e5 Remove unused futurewheel fixture 2020-01-31 19:33:51 -05:00
Chris Hunt e83e134f5f Use wheel_builder for future wheel functional test 2020-01-31 19:33:48 -05:00
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 f5684ed7ae Use shared_data fixture in wheel install tests
shared_data avoids copying the entire data directory, so use it in cases
where we know pip won't have any opportunity to edit the data files
(where we're passing tmpdir for --find-links).
2020-01-03 18:25:02 -05:00
Chris Hunt d468da2796 Explicitly copy required packages to tmpdir for wheel install tests
Any test using --find-links data.packages is potentially using several
packages. By copying specifically the packages we need, we can more
easily see the packages that each test depends on and avoid using the
`data` fixture.
2020-01-03 18:23:48 -05:00
Chris Hunt 4e5d854456 Normalize --find-links argument format in wheel install tests 2020-01-03 17:58:40 -05:00
Chris Hunt 7af9371176 Remove redundant expect_error=False in tests
This is the default, so there is no need to specify it explicitly.
2020-01-03 14:25:36 +01:00
Christopher Hunt 8c888a2287
Simplify getting info directories for wheel installation (#7526)
* Edit subdirs of top-level instead of checking in each directory

Previously, we were checking whether the top of the relative path ended
with .data. Now, we do not recurse into those directories, so there's no
need to check every time.

* Store info_dir in separate variable

Instead of working with a list everywhere, we use the single info_dir.

* Separate variables for info_dir and the destination path
* Use destination .dist-info dir only when needed

By initially storing just the name of the folder we ensure our code is
agnostic to the destination, so it'll be easier to install from a zip
later.

* Use os.listdir instead of os.walk for wheel dir population

Since we only execute any code when basedir == '', we only need the
top-level directories.

* Inline data_dirs calculation
* Inline info_dirs calculation
2019-12-30 23:59:23 +08:00
Chris Hunt 93900e1199 Only check for .dist-info directories at the top-level
Previously we were restricting to a single .dist-info directory anywhere
in the unpacked wheel directory. That was incorrect since only a
top-level .dist-info directory indicates a contained "package". Now we
limit our restriction to top-level .dist-info directories.
2019-12-28 15:49:08 -05:00
Chris Hunt e5495cf6a1 Raise UnsupportedWheel when .dist-info doesn't match name
This aligns with the previous behavior that would have enforced the
found .dist-info directory starting with the name of the package.

We raise UnsupportedWheel because it looks better in output than the
AssertionError (which includes traceback).
2019-12-21 21:27:49 -05:00
Chris Hunt 0d865d8fe3 Add test for multiple .dist-info in wheel 2019-12-21 10:51:57 -05:00
Pradyun Gedam 8981895b5e
Skip all failing tests when using venv
Our isolation logic for venv isn't correct and that is causing these
tests to fail. The culprits for this are:

  tests/lib/venv.py::VirtualEnvironment.user_site_packages
  tests/lib/venv.py::VirtualEnvironment.sitecustomize

Both these together are supposed to create an environment to isolate the
tests. However, they were written for virtualenv and make assumptions
that are not true for environments created with venv. Until we can fix
VirtualEnvironment to properly isolate the test from the underlying test
environment when using venv, these tests will continue to fail.

This is blocking an important bugfix for users facing issues with since
pip is installing packages into `--user` when run in a venv, even when
`--user` isn't visible from that environment.

As a temporary band-aid for this problem, I'm skipping these tests to
unblock us from shipping the bugfix for the aforementioned issue.

The test isolation logic should be fixed to work for venv. Once such a
fix is made, this commit should be reverted.
2019-11-05 23:02:45 +05:30
Chris Jerdonek 76a89542a8
Merge pull request #6856 from chrahunt/maint/remove-unneeded-expect-error-stderr
Remove unnecessary expect_error
2019-08-12 15:08:56 -07:00
Chris Hunt 0a6b3cedae Remove unnecessary expect_error. 2019-08-10 22:39:57 -04:00
Albert Tugushev aaf86008d0 Unskip pip install from wheel with headers
Closes #1373.
2019-08-06 01:28:28 +03:00
Chris Hunt 39ac9ca351 Rename compatible functions in tests.lib.path.Path. 2019-07-02 18:48:44 -04:00
Pradyun Gedam e55fcea956
Add tests for the bug 2019-01-23 09:48:04 +05:30
Benoit Pierre add3801163 tests: rework tests virtual environment
- cleanup virtualenv creation code
- ensure all testing virtual environments use a recent version
  of setuptools / wheel, making it easier to switch to custom
  versions of those, as well as reducing network accesses
- reduce size of testing virtual environment, slightly speeding
  up the testsuite
2018-10-18 23:28:37 +02:00
Bernhard M. Wiedemann f4bda78815 Sort list of RECORD entries
Without sorting, the 'installed' hash had entries in random order
that caused output to differ for every run.

See https://reproducible-builds.org/ for why this matters.

Sorting all entries to make testing easier.
2018-09-11 13:51:33 +02:00
Pradyun Gedam 54722aa7ec
Remove unused imports 2018-06-13 13:17:30 +05:30
Pradyun Gedam e31d784b41
Rename a few tests to add the word "basic"
This essentially allows me to do an overall check general check by running the tests using pytest's `-k basic` syntax. Given that I like running tests often and that, in general, I make typos more often than changes that break core functionality, I think this will reduce cycle times for me.
2017-12-16 23:43:46 +05:30
Benoit Pierre 961737ab98 Fix integration tests on Windows (#4769) 2017-10-06 20:51:42 +01:00
Xavier Fernandez b709b1ef4a Add a common_wheels fixtures providing wheel & setuptools wheels 2017-07-21 18:08:53 +02:00
Pradyun S. Gedam 9923c1ad7e Sort imports and minor Flake8 changes (#4520)
* Run isort on the codebase

Command: isort --recursive --skip __main__.py --skip _vendor -o pip._vendor -sd THIRDPARTY -m 5 -p pip -p tests ./pip ./tests

* 📰
2017-06-13 14:17:00 +02:00
Pradyun S. Gedam 1832569530 Sort all imports 2017-05-16 15:47:47 +05:30
fiber-space fa7aeb6cc8 Fixes destination directory of data_files when 'pip install --target' is used (#4092) (#4152) 2017-03-26 23:55:50 +02:00
Bruno Oliveira c73abf81db Avoid importing TestFailure at the top level
This will make pytest-3.0 emit a warning:

cannot collect test class 'TestFailure' because it has a __init__ constructor
2016-07-28 21:36:45 -03:00
Donald Stufft 3b3978b994 Merge pull request #3284 from ncoghlan/pep376-installer-file
Record pip in INSTALLER file
2016-01-19 10:41:08 -05:00
Jeff Barber 24a5cc6a42 Fix for issue #2834 with test 2016-01-03 17:38:36 -05:00
Nick Coghlan a925c88ed6 Record pip in INSTALLER file 2015-12-04 19:22:19 +10:00
Domen Kožar e14a66f1b9 Support --prefix argument to install command.
There was no way to override prefix for an installation for wheels
previously. The default it whatever sys.prefix points to.
2015-11-22 19:13:51 +01:00
Robert Collins 62041d3ca8 Cleanup now use_wheel is the default.
There were a bunch of tests passing use_wheel unnecessarily, this
makes the change to remove use_wheel larger than it needs to be.
2015-04-20 20:12:03 +12:00
Donald Stufft a88bc0de73 Send log messages >= logging.WARNING to stderr 2015-04-06 23:11:16 -04:00