It will be several days (heh) before all tests pass when using the curses
gui, but it's time to start planning.
Rev e29225c broadcasts test runner output to the logger when --gui=curses
is in effect. It's a hack, but better than the suggestions in stack
overflow. See the post script. The hack is not perfect: print output
still goes to the original console. This will mess up the console, but so
what: I'll be able to see the output from the unit tests in the listener
pane.
The next step will be to bind a new key to run-selected-unit-tests-locally.
It appears that curses can't handle Alt-4. I'll try Ctrl-4 instead.
The following script can be run regardless of gui. It reveals problems in
CKeyHandler.to_key:
import curses.ascii as a
import leo.plugins.cursesGui2 as cursesGui2
h = cursesGui2.CursesKeyHandler()
for i in range(256):
if i <= 32: # yes, there are 33 elements.
print('%3s %s' % (i, a.controlnames[i]))
else:
char, shortcut = h.to_key(i)
print('%3s %-8r %r' % (i, a.unctrl(i), shortcut))
I'll use this script to debug to_key and to pick a key that the curses gui
plugin can handle. I'll then be able to run unit tests while --gui=curses
is in effect.
The curses gui will be complete when, and only when, all curses-appropriate
unit tests pass.
Edward
P. S. Here is the hack (rev e29225c, in TM.doTests, in leoTest.py) that
broadcasts the test-runner output:
if g.app.gui.guiName() == 'curses':
import logging, logging.handlers
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
socketHandler = logging.handlers.SocketHandler(
'localhost',
logging.handlers.DEFAULT_TCP_LOGGING_PORT,
)
logger.addHandler(socketHandler)
class Log:
aList = []
def write(self, s):
prefix = ''.join(self.aList)
if s.isspace():
pass
elif s.endswith('\n') or len(prefix+s) > 50:
logger.info(prefix+s)
self.aList = []
else:
self.aList.append(s)
def flush(self):
pass
stream = Log()
else:
stream = None
runner = unittest.TextTestRunner(
stream=stream,
failfast=g.app.failFast,
verbosity=verbosity,
)
result = runner.run(suite)
if stream:
if stream.aList:
logger.info(''.join(stream.aList))
logger.removeHandler(socketHandler)
EKR
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.