joshgoebel / keyszer

a smart, flexible keymapper for X11 (a fork/reboot of xkeysnail )
Other
69 stars 15 forks source link

Update test_api_helpers.py for new processor functions #146

Open RedBearAK opened 1 year ago

RedBearAK commented 1 year ago

This updates test_api_helpers.py to allow it to function after the string and Unicode processor functions are updated to return inner functions, so that they can adjust to the state of the CapsLock LED.

Changes

Add two context object classes, so that the behavior of to_US_keystrokes and unicode_keystrokes can be evaluated after they are turned into functions that return functions (that return lists). In the simple case, the function can just have (ctx) added on the end. In the case where to_US_keystrokes is given a non-ASCII character to process, it returns a list with the Unicode inner function inside, so that needs to be extracted from the list returned by to_US_keystrokes and then given the context object in a new call, finally getting the combo list returned by the inner function of unicode_keystrokes.

One context object class is for the normal state of CapsLock OFF, the other is for testing the behavior when CapsLock is ON. Some test conditions have been added to test the CapsLock ON behavior.

All tests are passing for me.

Related to issue #128, and pull request #129 (which will close issue #128).

Checklist