tl;dr: Important core classes, including importer classes, could support a reload method, that would reload the file containing the class, and return a new instance of the class, ready to be used by unit tests.
This is an experimental idea. It won't revolutionize Leo's unit tests, but it might make them lighter and stronger.
Details
At present, Leo's unit tests support TDD using preamble code, like this:
if 0: # Preamble...
g.cls()
if c.isChanged(): c.save()
import leo.core.leoImport as leoImport
import leo.plugins.importers.linescanner as linescanner
import leo.plugins.importers.markdown
import leo.plugins.writers.markdown
import imp
imp.reload(leo.plugins.importers.linescanner)
imp.reload(leo.plugins.importers.markdown)
imp.reload(leo.plugins.writers.markdown)
imp.reload(leoImport)
ic = leoImport.LeoImportCommands(c)
else:
ic = c.importCommands
Cutting, pasting and modifying this template has been good enough, but we would like something better, maybe:
if 0: # Preamble...
g.cls()
if c.isChanged(): c.save()
ic.importers.linescanner.reload()
ic.importers.markdown.reload()
ic.writers.markdown.reload()
ic = c.importCommands.reload()
else:
ic = c.importCommands
To make this work, the importCommands class would have to have ivars for all readers & writers, or a __getattr__ method. It's worth looking into.
EKR