Lukas Juhrich
2e67986782
make linters happy
2021-10-23 17:42:22 +02:00
Lukas Juhrich
58996b5ddb
Add tests for BadZipFile
handling
...
Note that the functional test does not actually detect the behavioral
change of throwing unhandled `BadZipFile` → throwing unhandled
`InvalidWheel`, whereas the unit test does.
2021-10-23 17:42:22 +02:00
Jon Dufresne
60c274be2d
Complete type annotations of tests/unit/ directory
2021-09-23 05:44:54 -07:00
Tzu-ping Chung
135faabfd6
Remove direct pkg_resource usages from resolver and preparer
2021-08-23 02:07:33 +08:00
Tzu-ping Chung
d1d9bc5849
Add Python 3.10 workaround
2021-08-21 00:53:59 +08:00
Pradyun Gedam
94999255d5
Reformat the codebase, with black
2021-08-20 13:37:49 +01:00
Tzu-ping Chung
3bba1d34a2
Fix unit test setup to use BaseDistribution
2021-07-22 15:20:49 +08: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
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
ba40f58ecc
Remove encoding cookie from Python source files
...
Unnecessary since dropping Python 2. Python now decodes files as utf-8
by default.
2020-12-25 07:26:07 -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
58c594c06b
Prepare isort for black
2020-09-23 21:47:47 +05:30
4a2e03c4ff
Use monkeypatch for env var in wheel unit tests
2020-09-04 15:06:08 +07:00
Chris Hunt
05f2d9ebf6
Make entrypoint error test higher-level
...
The current tests didn't catch the bug that the new tests do,
so they have been removed. Using higher-level tests can give us more
confidence that things work end-to-end and are less likely to get in
the way of refactoring.
The new test has been marked xfail since the bug is still present.
2020-07-11 15:45:18 -04:00
Chris Hunt
d13ec25361
Prevent path traversal when installing wheels directly
2020-07-09 21:21:35 -04:00
Chris Hunt
ba96ba3b08
Reduce empty directory test coupling to implementation
...
Our previous test required that the implementation use a temporary
directory and unpack the wheel in-place. Now we just provide a
conventional empty directory in the wheel file itself.
2020-07-05 20:16:36 -04:00
Chris Hunt
a9c7f229b0
Create sample project wheel inline
2020-07-05 20:16:36 -04:00
Chris Hunt
42c01ae97e
Normalize Path to str in wheel tests
...
In our next commit we will use the scheme path to locate files to
byte-compile. If the scheme path is a `Path`, then that causes
`compileall.compile_file` (via `py_compile.compile`) to fail with:
```
.tox/py38/lib/python3.8/site-packages/pip/_internal/operations/install/wheel.py:615: in install_unpacked_wheel
success = compileall.compile_file(
../../../.pyenv/versions/3.8.0/lib/python3.8/compileall.py:157: in compile_file
ok = py_compile.compile(fullname, cfile, dfile, True,
../../../.pyenv/versions/3.8.0/lib/python3.8/py_compile.py:162: in compile
bytecode = importlib._bootstrap_external._code_to_timestamp_pyc(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = <code object <module> at 0x7fa7e274f500, file "/tmp/user/1000/pytest-of-chris/pytest-37/test_std_install_with_direct_u0/dest/lib/sample/__init__.py", line 1>, mtime = 1593910285.2200587, source_size = 134
> ???
E ValueError: unmarshallable object
```
Debugging in gdb shows that the error is set due to the `Path` object
being present in the code object, which `marshal.dumps` can't handle
(frame 1):
```
0 w_complex_object (v=<optimized out>, flag=<optimized out>, p=0x7fffffff7160) at Python/marshal.c:564
1 w_object (v=<Path at remote 0x7fffee51f120>, p=0x7fffffff7160) at Python/marshal.c:370
2 w_complex_object (v=<code at remote 0x7fffee591710>, flag=<optimized out>, p=0x7fffffff7160) at Python/marshal.c:544
3 w_object (v=<code at remote 0x7fffee591710>, p=0x7fffffff7160) at Python/marshal.c:370
4 w_complex_object (v=('1.2.0', <code at remote 0x7fffee591710>, 'main', None), flag=<optimized out>, p=0x7fffffff7160) at Python/marshal.c:475
5 w_object (v=('1.2.0', <code at remote 0x7fffee591710>, 'main', None), p=0x7fffffff7160) at Python/marshal.c:370
6 w_complex_object (v=<code at remote 0x7fffee591ea0>, flag=<optimized out>, p=0x7fffffff7160) at Python/marshal.c:539
7 w_object (p=0x7fffffff7160, v=<code at remote 0x7fffee591ea0>) at Python/marshal.c:370
8 PyMarshal_WriteObjectToString (version=<optimized out>, x=<code at remote 0x7fffee591ea0>) at Python/marshal.c:1598
9 marshal_dumps_impl (module=<optimized out>, version=<optimized out>, value=<code at remote 0x7fffee591ea0>) at Python/marshal.c:1739
10 marshal_dumps (module=<optimized out>, args=<optimized out>, nargs=<optimized out>) at Python/clinic/marshal.c.h:124
```
In the interest of easy git bisects, we commit this fix before the code
that would expose the bug.
2020-07-05 09:38:08 -04:00
Chris Hunt
3930e4b063
Drop unused argument
2020-07-03 19:46:45 -04:00
Chris Hunt
d49d97f19f
Pass Wheel distribution to install.wheel.get_entrypoints
...
Right now we're just wiring up the arguments. Next we will actually use
them.
2020-07-03 19:46:45 -04:00
Chris Hunt
a953787152
Extract entrypoint test text construction into variable
...
We need this to construct the new argument to `get_entrypoints`.
2020-07-03 19:46:45 -04:00
Chris Hunt
3fad029b77
Test get_entrypoints
when none are expected
2020-07-03 17:49:56 -04:00
Chris Hunt
dcd5cadcfd
Expect a plain list in get_csv_rows_for_installed
...
This makes get_csv_rows_for_installed simpler, because it is not
modifying its arguments. We can also more easily refactor RECORD file
reading since it is now decoupled from getting the installed RECORD file
rows.
2020-07-03 12:25:12 -04:00
Pradyun Gedam
e774eccf46
Merge pull request #8343 from uranusjr/entrypoint-unicode
2020-06-30 14:33:24 +00:00
Tzu-ping Chung
b0c1308d64
Always Unicode
2020-06-10 20:58:21 +08: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
Stéphane Bidoul
c9a445762c
Mark top level requirements as REQUESTED
2020-05-31 18:33:51 +02:00
Stéphane Bidoul
21df86f197
Add REQUESTED support to install_wheel
2020-05-31 18:33:50 +02:00
Tzu-ping Chung
aef15104c3
Fix test comment
2020-05-19 16:03:51 +08:00
Tzu-ping Chung
776a55a419
Fix unit tests on module-internal functions
2020-05-19 16:03:51 +08:00
Devesh Kumar Singh
8dccece9c0
Combine setting new umask and getting old one into one
2020-04-29 11:57:11 +05:30
Devesh Kumar Singh
9319703ad9
Add unit test for checking permissions with custom umask
2020-04-29 11:46:43 +05:30
Tzu-ping Chung
adef52610e
Fix assertion
2020-04-26 18:22:21 +08:00
Tzu-ping Chung
9af0b3daeb
Use oct for better error message
2020-04-26 18:17:33 +08:00
Tzu-ping Chung
388ca923ef
Add persumably failing permission check
2020-04-26 18:14:38 +08:00
Stéphane Bidoul
f77944733d
Add DirectUrl support to install_wheel
2020-04-01 22:56:59 +02:00
209c74f690
Use better temporary files mechanism
2020-04-01 22:02:34 +07:00
Chris Hunt
b263fcc105
Move parse_wheel and supporting functions to utils.wheel
...
In order to parse metadata from wheel files directly we want to reuse
parse_wheel. Moving it out helps avoid creating an unnecessary
dependence on operations.install.wheel.
2020-01-04 23:11:51 +01:00
Chris Hunt
d5b4c15105
Remove dead code from wheel_metadata
...
Since we don't pass the source directory anymore, remove the tests
and implementation.
2020-01-01 17:51:24 -05:00
Chris Hunt
a2af0f9468
Get WHEEL metadata from wheel file directly
2020-01-01 17:26:20 -05:00
Chris Hunt
62721eb5da
Remove dead code
...
Since we don't pass the source dir anymore, we can simplify the tests
and implementation for wheel_dist_info_dir.
2020-01-01 17:26:20 -05:00
Chris Hunt
cd5400ceb9
Determine .dist-info directory from wheel file directly
...
First example of transitioning a directory-aware function to using a
zipfile directly. Since we will not need to maintain the unpacked dir
going forward, we don't need to worry about making wheel_dist_info_dir
"generic", just that the same tests pass for both cases at each commit.
To do this neatly we use pytest.fixture(params=[...]), which
generates a test for each param. Once we've transitioned the
necessary functions we only need to replace the fixture name and remove
the dead code.
2020-01-01 17:26:20 -05:00
Chris Hunt
452acd5e76
Add files in .dist-info directory tests
...
Since zips don't typically contain directory entries, we want to
only operate on files. Adding files to the .dist-info tests means we
will be able to reuse them for both cases, while they coexist.
2020-01-01 17:26:20 -05:00
Chris Hunt
010c24d64c
Take .dist-info dir directly in wheel_metadata
...
Since retrieval of the .dist-info dir already ensures that a
distribution is found, this reduces responsibility on wheel_metadata and
lets us remove a few tests already covered by the tests for
test_wheel_dist_info_dir_*.
2020-01-01 12:25:01 -05:00
Chris Hunt
fc48a17206
Simplify positive wheel_version unit test
2020-01-01 12:25:01 -05:00
Chris Hunt
6c56557fbe
Remove unused req_description from wheel_dist_info_dir
2020-01-01 12:25:01 -05:00
Chris Hunt
e1c7de8861
Raise UnsupportedWheel instead of AssertionError, and let caller add name
2020-01-01 12:25:01 -05:00
Chris Hunt
32115b55af
Extract getting wheel .dist-info directory into a separate function
2020-01-01 12:10:22 -05:00