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
#
# (C) Copyright 2023 Enthought, Inc., Austin, TX
# All right reserved.
#
# This file is open source software distributed according to the terms in
# LICENSE.txt
#
import importlib
import unittest
 
from win32ctypes.core import _backend
 
_modules = [
    '_dll', '_authentication', '_time', '_common',
    '_resource',  '_nl_support', '_system_information']
 
 
class TestBackends(unittest.TestCase):
 
    @unittest.skipIf(_backend != 'cffi', 'cffi backend not enabled')
    def test_backend_cffi_load(self):
        # when/then
        for name in _modules:
            module = importlib.import_module(f'win32ctypes.core.{name}')
            self.assertEqual(
                module.__spec__.name, f'win32ctypes.core.{name}')
            self.assertTrue(module.__file__.endswith(f'cffi\\{name}.py'))
 
    @unittest.skipIf(_backend != 'ctypes', 'ctypes backend not enabled')
    def test_backend_ctypes_load(self):
        # when/then
        for name in _modules:
            module = importlib.import_module(f'win32ctypes.core.{name}')
            self.assertEqual(
                module.__spec__.name, f'win32ctypes.core.{name}')
            self.assertTrue(module.__file__.endswith(f'ctypes\\{name}.py'))