|
3 | 3 | import logging
|
4 | 4 | import os
|
5 | 5 | import pathlib
|
| 6 | +import sys |
6 | 7 | import textwrap
|
7 | 8 | from email import message_from_string
|
8 | 9 | from pathlib import Path
|
|
22 | 23 | from pip._internal.models.scheme import Scheme
|
23 | 24 | from pip._internal.operations.build.wheel_legacy import get_legacy_build_wheel_path
|
24 | 25 | from pip._internal.operations.install import wheel
|
25 |
| -from pip._internal.operations.install.wheel import InstalledCSVRow, RecordPath |
| 26 | +from pip._internal.operations.install.wheel import ( |
| 27 | + InstalledCSVRow, |
| 28 | + RecordPath, |
| 29 | + get_console_script_specs, |
| 30 | +) |
26 | 31 | from pip._internal.utils.compat import WINDOWS
|
27 | 32 | from pip._internal.utils.misc import hash_file
|
28 | 33 | from pip._internal.utils.unpacking import unpack_file
|
@@ -681,3 +686,31 @@ def test_rehash(self, tmpdir: Path) -> None:
|
681 | 686 | h, length = wheel.rehash(os.fspath(self.test_file))
|
682 | 687 | assert length == str(self.test_file_len)
|
683 | 688 | assert h == self.test_file_hash_encoded
|
| 689 | + |
| 690 | + |
| 691 | +def test_get_console_script_specs_replaces_python_version( |
| 692 | + monkeypatch: pytest.MonkeyPatch, |
| 693 | +) -> None: |
| 694 | + # Fake Python version. |
| 695 | + monkeypatch.setattr(sys, "version_info", (10, 11)) |
| 696 | + |
| 697 | + entry_points = { |
| 698 | + "pip": "real_pip", |
| 699 | + "pip99": "whatever", |
| 700 | + "pip99.88": "whatever", |
| 701 | + "easy_install": "real_easy_install", |
| 702 | + "easy_install-99.88": "whatever", |
| 703 | + # The following shouldn't be replaced. |
| 704 | + "not_pip_or_easy_install-99": "whatever", |
| 705 | + "not_pip_or_easy_install-99.88": "whatever", |
| 706 | + } |
| 707 | + specs = get_console_script_specs(entry_points) |
| 708 | + assert specs == [ |
| 709 | + "pip = real_pip", |
| 710 | + "pip10 = real_pip", |
| 711 | + "pip10.11 = real_pip", |
| 712 | + "easy_install = real_easy_install", |
| 713 | + "easy_install-10.11 = real_easy_install", |
| 714 | + "not_pip_or_easy_install-99 = whatever", |
| 715 | + "not_pip_or_easy_install-99.88 = whatever", |
| 716 | + ] |
0 commit comments