Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Pdm
提交
bfc82792
P
Pdm
项目概览
后端镜像
/
Pdm
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Pdm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
bfc82792
编写于
7月 21, 2022
作者:
F
Frost Ming
提交者:
GitHub
7月 21, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: detect available python versions for integration (#1249)
上级
a7879780
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
43 addition
and
24 deletion
+43
-24
.github/workflows/ci.yml
.github/workflows/ci.yml
+1
-0
pdm/project/core.py
pdm/project/core.py
+6
-3
tests/cli/test_venv.py
tests/cli/test_venv.py
+5
-1
tests/conftest.py
tests/conftest.py
+2
-6
tests/test_integration.py
tests/test_integration.py
+29
-14
未找到文件。
.github/workflows/ci.yml
浏览文件 @
bfc82792
...
...
@@ -113,6 +113,7 @@ jobs:
-
name
:
Install Dev Dependencies
run
:
|
pdm install -v -dGtest
pdm run pip install -U setuptools
pdm info
-
name
:
Run Tests
run
:
pdm run pytest -n auto --cov=pdm --cov-config=setup.cfg --cov-report=xml tests
...
...
pdm/project/core.py
浏览文件 @
bfc82792
...
...
@@ -125,9 +125,12 @@ class Project:
@
property
def
pyproject
(
self
)
->
dict
|
None
:
if
not
self
.
_pyproject
and
self
.
pyproject_file
.
exists
():
data
=
tomlkit
.
parse
(
self
.
pyproject_file
.
read_text
(
"utf-8"
))
self
.
_pyproject
=
cast
(
dict
,
data
)
if
not
self
.
_pyproject
:
if
self
.
pyproject_file
.
exists
():
data
=
tomlkit
.
parse
(
self
.
pyproject_file
.
read_text
(
"utf-8"
))
self
.
_pyproject
=
cast
(
dict
,
data
)
else
:
self
.
_pyproject
=
cast
(
dict
,
tomlkit
.
document
())
return
self
.
_pyproject
@
pyproject
.
setter
...
...
tests/cli/test_venv.py
浏览文件 @
bfc82792
...
...
@@ -127,8 +127,12 @@ def test_venv_activate_error(invoke, project):
assert
result
.
exit_code
!=
0
assert
"No virtualenv with key"
in
result
.
stderr
project
.
project_config
[
"python.path"
]
=
next
(
project
.
find_interpreters
()
).
path
.
as_posix
()
result
=
invoke
([
"venv"
,
"activate"
],
obj
=
project
)
assert
result
.
exit_code
!=
0
print
(
project
.
project_config
.
get
(
"python.path"
))
assert
result
.
exit_code
!=
0
,
result
.
output
+
result
.
stderr
assert
"Can't activate a non-venv Python"
in
result
.
stderr
...
...
tests/conftest.py
浏览文件 @
bfc82792
...
...
@@ -18,7 +18,7 @@ from packaging.version import parse as parse_version
from
unearth.vcs
import
Git
,
vcs_support
from
pdm._types
import
CandidateInfo
from
pdm.cli.actions
import
do_init
,
do_use
from
pdm.cli.actions
import
do_init
from
pdm.cli.hooks
import
HookManager
from
pdm.core
import
Core
from
pdm.exceptions
import
CandidateInfoNotFound
...
...
@@ -290,11 +290,7 @@ def project_no_init(tmp_path, mocker, core, index, monkeypatch):
)
tmp_path
.
joinpath
(
"caches"
).
mkdir
(
parents
=
True
)
p
.
global_config
[
"cache_dir"
]
=
tmp_path
.
joinpath
(
"caches"
).
as_posix
()
do_use
(
p
,
getattr
(
sys
,
"_base_executable"
,
sys
.
executable
),
HookManager
(
p
,
[
"post_use"
]),
)
p
.
project_config
[
"python.path"
]
=
getattr
(
sys
,
"_base_executable"
,
sys
.
executable
)
monkeypatch
.
delenv
(
"VIRTUAL_ENV"
,
raising
=
False
)
monkeypatch
.
delenv
(
"CONDA_PREFIX"
,
raising
=
False
)
monkeypatch
.
delenv
(
"PEP582_PACKAGES"
,
raising
=
False
)
...
...
tests/test_integration.py
浏览文件 @
bfc82792
import
findpython
import
pytest
from
pdm.utils
import
cd
PYTHON_VERSIONS
=
[
"3.6"
,
"3.7"
,
"3.8"
,
"3.9"
,
"3.10"
,
"3.11"
]
PYPROJECT
=
"""
\
[project]
name = "test-project"
version = "0.1.0"
requires-python = ">=3.6"
[build-system]
requires = ["pdm-pep517"]
build-backend = "pdm.pep517.api"
"""
def
get_python_versions
():
finder
=
findpython
.
Finder
(
resolve_symlinks
=
True
)
available_versions
=
[]
for
version
in
PYTHON_VERSIONS
:
v
=
finder
.
find
(
version
)
if
v
and
v
.
is_valid
():
available_versions
.
append
(
version
)
return
available_versions
@
pytest
.
mark
.
integration
@
pytest
.
mark
.
network
@
pytest
.
mark
.
parametrize
(
"python_version"
,
[
"3.6"
,
"3.7"
,
"3.8"
,
"3.9"
,
"3.10"
]
)
@
pytest
.
mark
.
parametrize
(
"python_version"
,
get_python_versions
()
)
def
test_basic_integration
(
python_version
,
core
,
tmp_path
,
invoke
):
"""An e2e test case to ensure PDM works on all supported Python versions"""
project
=
core
.
create_project
(
tmp_path
)
project
.
pyproject_file
.
write_text
(
PYPROJECT
)
project
.
root
.
joinpath
(
"foo.py"
).
write_text
(
"import django
\n
"
)
additional_args
=
[
"--no-self"
]
if
python_version
==
"2.7"
else
[]
project
.
_environment
=
project
.
pyproject
=
None
invoke
([
"use"
,
"-f"
,
python_version
],
obj
=
project
,
strict
=
True
)
invoke
([
"init"
,
"-n"
],
obj
=
project
,
strict
=
True
)
project
.
meta
[
"name"
]
=
"test-project"
project
.
meta
[
"version"
]
=
"0.1.0"
project
.
meta
[
"requires-python"
]
=
">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*"
project
.
write_pyproject
()
project
.
_environment
=
None
invoke
([
"add"
,
"django"
,
"-v"
]
+
additional_args
,
obj
=
project
,
strict
=
True
)
invoke
([
"add"
,
"django"
,
"-v"
],
obj
=
project
,
strict
=
True
)
with
cd
(
project
.
root
):
invoke
([
"run"
,
"python"
,
"foo.py"
],
obj
=
project
,
strict
=
True
)
if
python_version
!=
"2.7"
:
invoke
([
"build"
,
"-v"
],
obj
=
project
,
strict
=
True
)
invoke
([
"remove"
,
"-v"
,
"django"
]
+
additional_args
,
obj
=
project
,
strict
=
True
)
invoke
([
"build"
,
"-v"
],
obj
=
project
,
strict
=
True
)
invoke
([
"remove"
,
"-v"
,
"django"
],
obj
=
project
,
strict
=
True
)
result
=
invoke
([
"list"
],
obj
=
project
,
strict
=
True
)
assert
not
any
(
line
.
strip
().
lower
().
startswith
(
"django"
)
for
line
in
result
.
output
.
splitlines
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录