FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
winpython/tests/test_cli.py at master · winpython/winpython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
winpython
/
winpython
Public
Notifications
You must be signed in to change notification settings
Fork
350
Star
2.3k
Code
Issues
79
Pull requests
0
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
winpython
/
tests
/
test_cli.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
111 lines (85 loc) · 4.18 KB
Breadcrumbs
winpython
/
tests
/
test_cli.py
Copy path
File metadata and controls
111 lines (85 loc) · 4.18 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# -*- coding: utf-8 -*-
"""End-to-end: run the wppm CLI against a real venv.
These are the commands that returned "OSError: Invalid Python distribution"
for any venv before the target-resolution fix.
"""
import
json
import
subprocess
import
sys
from
pathlib
import
Path
import
pytest
from
conftest
import
windows_only
REPO_ROOT
=
Path
(
__file__
).
resolve
().
parent
.
parent
pytestmark
=
windows_only
def
wppm
(
*
args
,
expect_ok
=
True
):
"""Run `python -m wppm ...` from the repo, not from an installed copy."""
proc
=
subprocess
.
run
(
[
sys
.
executable
,
"-X"
,
"utf8"
,
"-m"
,
"wppm"
,
*
args
],
capture_output
=
True
,
text
=
True
,
cwd
=
str
(
REPO_ROOT
),
timeout
=
300
,
encoding
=
"utf-8"
,
errors
=
"replace"
,
)
if
expect_ok
:
assert
proc
.
returncode
==
0
,
f"exit
{
proc
.
returncode
}
\n
{
proc
.
stdout
}
\n
{
proc
.
stderr
}
"
return
proc
class
TestListing
:
def
test_lists_packages_of_a_venv
(
self
,
real_venv
):
out
=
wppm
(
"-t"
,
str
(
real_venv
),
"-ls"
).
stdout
assert
"pip"
in
out
def
test_scripts_target_gives_the_same_listing
(
self
,
real_venv
):
"""-t <venv>
\\
Scripts used to print nothing at all."""
root
=
wppm
(
"-t"
,
str
(
real_venv
),
"-ls"
).
stdout
scripts
=
wppm
(
"-t"
,
str
(
real_venv
/
"Scripts"
),
"-ls"
).
stdout
assert
scripts
.
strip
()
==
root
.
strip
()
assert
"pip"
in
scripts
def
test_json_listing_is_valid_json
(
self
,
real_venv
):
out
=
wppm
(
"-t"
,
str
(
real_venv
),
"-ls"
,
"pip"
,
"-j"
).
stdout
assert
any
(
row
[
"package"
]
==
"pip"
for
row
in
json
.
loads
(
out
))
def
test_filters_by_expression
(
self
,
real_venv
):
out
=
wppm
(
"-t"
,
str
(
real_venv
),
"-ls"
,
"^pip$"
,
"-j"
).
stdout
assert
[
r
[
"package"
]
for
r
in
json
.
loads
(
out
)]
==
[
"pip"
]
def
test_does_not_list_the_running_interpreters_packages
(
self
,
real_venv
):
"""A -t listing must describe the target, not whatever runs wppm."""
names
=
{
r
[
"package"
]
for
r
in
json
.
loads
(
wppm
(
"-t"
,
str
(
real_venv
),
"-ls"
,
"-j"
).
stdout
)}
assert
"pytest"
not
in
names
class
TestTrees
:
def
test_downward_tree
(
self
,
real_venv
):
assert
"pip=="
in
wppm
(
"-t"
,
str
(
real_venv
),
"-p"
,
"pip"
,
"-l1"
).
stdout
def
test_upward_tree
(
self
,
real_venv
):
assert
"pip=="
in
wppm
(
"-t"
,
str
(
real_venv
),
"-r"
,
"pip"
,
"-l1"
).
stdout
def
test_tree_json_parses
(
self
,
real_venv
):
out
=
wppm
(
"-t"
,
str
(
real_venv
),
"-p"
,
"pip"
,
"-l1"
,
"-j"
).
stdout
assert
json
.
loads
(
out
)
class
TestMarkdown
:
def
test_generates_a_package_index
(
self
,
real_venv
):
out
=
wppm
(
"-t"
,
str
(
real_venv
),
"-md"
).
stdout
assert
"### Python packages"
in
out
assert
"pip"
in
out
def
test_reports_plain_python_not_winpython
(
self
,
real_venv
):
"""WINPYVER2 is unset here, so it must not claim to be WinPython."""
assert
"## Python"
in
wppm
(
"-t"
,
str
(
real_venv
),
"-md"
).
stdout
def
test_tools_section_reports_the_target_python_version
(
self
,
real_venv
):
"""Sanity check only: this venv comes from the running interpreter, so it
cannot tell target from runner -- test_distribution.py does that.
"""
data
=
json
.
loads
(
wppm
(
"-t"
,
str
(
real_venv
),
"-md"
,
"-j"
).
stdout
)
tools
=
{
t
[
"name"
]:
t
[
"version"
]
for
t
in
data
[
"tools"
]}
expected
=
subprocess
.
run
(
[
str
(
real_venv
/
"Scripts"
/
"python.exe"
),
"-c"
,
"import platform;print(platform.python_version())"
],
capture_output
=
True
,
text
=
True
,
).
stdout
.
strip
()
assert
tools
[
"Python"
].
startswith
(
expected
)
def
test_json_manifest_has_the_expected_shape
(
self
,
real_venv
):
data
=
json
.
loads
(
wppm
(
"-t"
,
str
(
real_venv
),
"-md"
,
"-j"
).
stdout
)
assert
set
(
data
)
>=
{
"distribution"
,
"tools"
,
"packages"
,
"wheelhouse"
}
assert
set
(
data
[
"distribution"
])
>=
{
"name"
,
"version"
,
"python_version"
}
class
TestBadTarget
:
def
test_rejects_a_directory_that_is_not_a_python
(
self
,
tmp_path
):
proc
=
wppm
(
"-t"
,
str
(
tmp_path
),
"-md"
,
expect_ok
=
False
)
assert
proc
.
returncode
!=
0
assert
"Invalid Python distribution"
in
proc
.
stdout
+
proc
.
stderr
class
TestHelp
:
def
test_help_mentions_the_version
(
self
):
from
wppm
import
__version__
assert
__version__
in
wppm
(
"-h"
).
stdout
Back
|
FazBrowse Home
|
New Git URL