FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
hatch-cpp/hatch_cpp/tests/test_projects.py at main · python-project-templates/hatch-cpp · GitHub
python-project-templates
hatch-cpp
Repository navigation
Code
Issues
4
(4)
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
hatch-cpp
/
hatch_cpp
/
tests
/
test_projects.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
65 lines (55 loc) · 2.07 KB
Breadcrumbs
hatch-cpp
/
hatch_cpp
/
tests
/
test_projects.py
Copy path
File metadata and controls
65 lines (55 loc) · 2.07 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
import
contextlib
from
os
import
listdir
,
remove
from
pathlib
import
Path
from
subprocess
import
check_call
from
sys
import
modules
,
path
,
platform
from
sysconfig
import
get_config_var
import
pytest
class
TestProject
:
@
pytest
.
mark
.
parametrize
(
"project"
,
[
"test_project_basic"
,
"test_project_override_classes"
,
"test_project_override_toolchain"
,
"test_project_pybind"
,
"test_project_pybind_vcpkg"
,
"test_project_nanobind"
,
"test_project_limited_api"
,
"test_project_cmake"
,
"test_project_cmake_vcpkg"
,
],
)
def
test_basic
(
self
,
project
):
suffix_ext
=
get_config_var
(
"EXT_SUFFIX"
)
# cleanup
with
contextlib
.
suppress
(
FileNotFoundError
):
remove
(
f"hatch_cpp/tests/
{
project
}
/project/extension.so"
)
with
contextlib
.
suppress
(
FileNotFoundError
):
remove
(
f"hatch_cpp/tests/
{
project
}
/project/extension.pyd"
)
with
contextlib
.
suppress
(
FileNotFoundError
):
remove
(
f"hatch_cpp/tests/
{
project
}
/project/extension
{
suffix_ext
}
"
)
modules
.
pop
(
"project"
,
None
)
modules
.
pop
(
"project.extension"
,
None
)
# compile
check_call
(
[
"hatch-build"
,
"--hooks-only"
,
],
cwd
=
f"hatch_cpp/tests/
{
project
}
"
,
)
# assert built
project_dir_content
=
listdir
(
f"hatch_cpp/tests/
{
project
}
/project"
)
if
project
==
"test_project_limited_api"
and
platform
!=
"win32"
:
assert
"extension.abi3.so"
in
project_dir_content
else
:
if
platform
==
"win32"
:
assert
"extension.pyd"
in
project_dir_content
or
f"extension
{
suffix_ext
}
"
in
project_dir_content
else
:
assert
"extension.so"
in
project_dir_content
or
f"extension
{
suffix_ext
}
"
in
project_dir_content
# import
here
=
Path
(
__file__
).
parent
/
project
path
.
insert
(
0
,
str
(
here
))
import
project
.
extension
assert
project
.
extension
.
hello
()
==
"A string"
Back
|
FazBrowse Home
|
New Git URL