You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am developing support for smarACT stages and I'd like to write a few tests. It's nothing fancy, but for instance trying to connect to the stage and checkingthe serial number, or changing a setting on the stage and checking that that's properly done. For this kind of stuff it typically makes sense to add some unit tests. For this, it's nice not to have to start up imswitch which can take quite a while. After some trial and error I found a way to do this (at the bottom).
I basically have two questions:
Is this the right way to do it?
If so, where should I add this?
Before I file the pull request, I'll ask smaract to take a look at the wrapper, that we're not adding something that ruins someone's stage.
importnumpyasnpfromimswitch.imcontrol.modelimportconfigfiletoolsfromimswitch.imcontrol.model.managers.positioners.SmarACTPositionerManagerimportSmarACTPositionerManagerfromunittestimportTestCaseimportloggingfromimswitch.imcontrol.viewimportViewSetupInfologger=logging.getLogger('test stage')
logging.basicConfig(level=logging.INFO)
OK_to_run=TrueclassTestSmarACTPositionManager(TestCase):
defsetUp(self) ->None:
globalOK_to_runifOK_to_runisNone:
print(
'WARNING!!! This is a hardware test. The stage will move in random directions. Only run this if that is safe')
answer=input('Continue? [n]')
ifanswer.lower() !='y':
OK_to_run=Falseelse:
OK_to_run=TrueelifOK_to_runisFalse:
raiseRuntimeError('Cannot run test as running hasnt been confirmed')
options, optionsDidNotExist=configfiletools.loadOptions()
setupInfo=configfiletools.loadSetupInfo(options, ViewSetupInfo)
p_info=setupInfo.positioners['SmarACT']
self.drive: SmarACTPositionerManager=SmarACTPositionerManager(positionerInfo=p_info, name='something')
deftearDown(self) ->None:
self.drive.finalize()
The text was updated successfully, but these errors were encountered:
Hi @dboonz , did you manage?
Normally they are in the folder _tests , but I don't know if it would make sense with hardware, since you would need to have it on to test it and in Github it would fail. I guess for that the best is to have a test that first tries to initialize the real device and otherwise initializes a mock one and still tests all its functions.
I am developing support for smarACT stages and I'd like to write a few tests. It's nothing fancy, but for instance trying to connect to the stage and checkingthe serial number, or changing a setting on the stage and checking that that's properly done. For this kind of stuff it typically makes sense to add some unit tests. For this, it's nice not to have to start up imswitch which can take quite a while. After some trial and error I found a way to do this (at the bottom).
I basically have two questions:
Before I file the pull request, I'll ask smaract to take a look at the wrapper, that we're not adding something that ruins someone's stage.
The text was updated successfully, but these errors were encountered: