forked from MatthieuDartiailh/pyclibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_init.py
46 lines (35 loc) · 1.33 KB
/
test_init.py
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
# -----------------------------------------------------------------------------
# Copyright 2015-2022 by PyCLibrary Authors, see AUTHORS for more details.
#
# Distributed under the terms of the MIT/X11 license.
#
# The full license is in the file LICENCE, distributed with this software.
# -----------------------------------------------------------------------------
"""Test init mechanisms."""
import pyclibrary.c_library as cl
import pyclibrary.c_parser as cp
import pytest
from pyclibrary.init import auto_init, init
@pytest.fixture
def init_fixture():
cp.CParser._init = False
cl.CLibrary._init = False
yield
def test_init(init_fixture):
init({"new_type": int}, ["__modifier"])
assert "new_type" in cp.base_types
assert cp.extra_modifier is not None
from pyclibrary.backends.ctypes import CTypesCLibrary
assert "new_type" in CTypesCLibrary._types_
def test_reinit_attempt(init_fixture):
init()
with pytest.raises(RuntimeError):
init()
def test_auto_init(init_fixture):
auto_init({"new_type": int}, ["__modifier"], "win32")
assert "new_type" in cp.base_types
assert "__int64" in cp.base_types
assert cp.extra_modifier is not None
from pyclibrary.backends.ctypes import CTypesCLibrary
assert "new_type" in CTypesCLibrary._types_
assert "__int64" in CTypesCLibrary._types_