|
15 | 15 | from packaging.tags import sys_tags |
16 | 16 | from ptvsd_folder_name import ptvsd_folder_name |
17 | 17 |
|
18 | | -from .. import PYTHONFILES, REQUIREMENTS |
19 | | - |
20 | | - |
21 | | -def open_requirements_with_ptvsd(): |
22 | | - return patch( |
23 | | - "ptvsd_folder_name.open", mock_open(read_data="jedi==0.15.1\nptvsd==5.0.0") |
24 | | - ) |
25 | | - |
26 | | - |
27 | | -def open_requirements_without_ptvsd(): |
28 | | - return patch("ptvsd_folder_name.open", mock_open(read_data="jedi==0.15.1\n")) |
| 18 | +from .. import PYTHONFILES |
29 | 19 |
|
30 | 20 |
|
31 | 21 | class TestPtvsdFolderName: |
32 | 22 | """Unit tests for the script retrieving the PTVSD folder name for the PTVSD wheels experiment.""" |
33 | 23 |
|
34 | | - def test_requirement_exists_folder_exists(self, capsys): |
| 24 | + def test_folder_exists(self, capsys): |
35 | 25 | # Return the first constructed folder path as existing. |
36 | 26 |
|
37 | 27 | patcher = patch("os.path.exists") |
38 | 28 | mock_exists = patcher.start() |
39 | 29 | mock_exists.side_effect = lambda p: True |
40 | 30 | tag = next(sys_tags()) |
41 | | - folder = "ptvsd-5.0.0-{}-{}-{}".format(tag.interpreter, tag.abi, tag.platform) |
| 31 | + folder = "ptvsd-{}-{}-{}".format(tag.interpreter, tag.abi, tag.platform) |
42 | 32 |
|
43 | | - with open_requirements_with_ptvsd(): |
44 | | - ptvsd_folder_name() |
| 33 | + ptvsd_folder_name() |
45 | 34 |
|
46 | 35 | patcher.stop() |
47 | 36 | expected = os.path.join(PYTHONFILES, folder) |
48 | 37 | captured = capsys.readouterr() |
49 | 38 | assert captured.out == expected |
50 | 39 |
|
51 | | - def test_ptvsd_requirement_once(self): |
52 | | - reqs = [ |
53 | | - line |
54 | | - for line in open(REQUIREMENTS, "r", encoding="utf-8") |
55 | | - if re.match("ptvsd==", line) |
56 | | - ] |
57 | | - assert len(reqs) == 1 |
58 | | - |
59 | | - def test_no_ptvsd_requirement(self, capsys): |
60 | | - with open_requirements_without_ptvsd() as p: |
61 | | - ptvsd_folder_name() |
62 | | - |
63 | | - expected = PYTHONFILES |
64 | | - captured = capsys.readouterr() |
65 | | - assert captured.out == expected |
66 | | - |
67 | 40 | def test_no_wheel_folder(self, capsys): |
68 | 41 | # Return none of of the constructed paths as existing, |
69 | 42 | # ptvsd_folder_name() should return the path to default ptvsd. |
70 | 43 | patcher = patch("os.path.exists") |
71 | 44 | mock_no_exist = patcher.start() |
72 | 45 | mock_no_exist.side_effect = lambda p: False |
73 | 46 |
|
74 | | - with open_requirements_with_ptvsd() as p: |
75 | | - ptvsd_folder_name() |
| 47 | + ptvsd_folder_name() |
76 | 48 |
|
77 | 49 | patcher.stop() |
78 | 50 | expected = PYTHONFILES |
|
0 commit comments