PyFixate / Fixate

Framework for hardware test fixtures and automatic test environments
MIT License
22 stars 16 forks source link

Introspection, instantiation, script convenience, comprehension... #193

Open clint-lawrence opened 3 months ago

clint-lawrence commented 3 months ago

Trying to unravel my thoughts on a few things here. Eventually I would like to be able to introspect a script and be able to do things like:

For many objects, there is no trade off to make. The script just defines test classes etc. Builds a test list from test class instances. Because instantiating a test class has no side effects, this works fine. (At least, it should have no side effects!)

The tricky bit comes when software meets the "real world". JigDriver and other instrument drivers need to open hardware connections. That is, that have side effects. I'll use the example of an AddressHandler, but this can be extended to JigDriver and other instruments.

There are two options: 1) Define a (sub)class that can be introspected, create an instance to open hardware resources. 2) The class can accept parameters to init to customise it (pin list, hardware address etc), but then it needs an open method, so we can instantiate without invoking side effects.

A test script defines a sub-class of AddressHandler with the required customisation needed for that script. Then JigDriver can be passed the class. Introspect the class as needed without instantiating. When ready to create an instance, just call the class and leave it up to init to create/open the required hardware resource, but that doesn't happen until it is needed. This flows up through the whole structure:

driver manager jig driver address handler

And we want everything to be typed, so we can check and get decent IDE support...