Debian Codegraph @

test-crates/with-data/check_installed/check_installed.py

raw
1 import locale
2 import sys
3 from pathlib import Path
4
5 import with_data
6
7 assert with_data.lib.one() == 1
8 assert with_data.ffi.string(with_data.lib.say_hello()).decode() == "hello"
9
10 venv_root = Path(sys.prefix)
11
12 installed_data = (
13 venv_root.joinpath("data_subdir")
14 .joinpath("hello.txt")
15 # With the default encoding, python under windows fails to read the file correctly
16 .read_text(encoding="utf-8")
17 .strip()
18 )
19 assert installed_data == "Hi! 😊", (
20 installed_data,
21 "Hi! 😊",
22 locale.getpreferredencoding(),
23 )
24 header_file = (
25 venv_root.joinpath("include")
26 .joinpath("site")
27 .joinpath(f"python{sys.version_info.major}.{sys.version_info.minor}")
28 .joinpath("with-data")
29 .joinpath("empty.h")
30 )
31 assert header_file.is_file(), header_file
32
33 print("SUCCESS")