Instead of indexing `Key` objects that have multiple names by each individual name, index by the set of names. This reduces the size of the default key dictionary by a factor of between 2 and 3, and as result also reduces reallocations/defragmentation. Instead of instantiating all module/extension keys by default, append them to the `maybe_key`-generator list.
30 lines
657 B
Python
30 lines
657 B
Python
import unittest
|
|
|
|
from kmk.keys import KC
|
|
from kmk.modules.layers import Layers
|
|
from tests.keyboard_test import KeyboardTest
|
|
|
|
|
|
class TestLayers(unittest.TestCase):
|
|
def setUp(self):
|
|
KC.clear()
|
|
self.kb = KeyboardTest(
|
|
[Layers()],
|
|
[
|
|
[KC.N0, KC.LM(1, KC.LCTL)],
|
|
[KC.A, KC.B],
|
|
],
|
|
debug_enabled=False,
|
|
)
|
|
|
|
def test_layermod(self):
|
|
self.kb.test(
|
|
'Layer + Mod',
|
|
[(1, True), (0, True), (1, False), (0, False)],
|
|
[{KC.LCTL}, {KC.LCTL, KC.A}, {KC.A}, {}],
|
|
)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|