commit 0e2a6445b2252e01acd971f444ccf095f6c40756 Author: Sambuddha Basu sambuddhabasu1@gmail.com Date: Sun Jun 26 13:33:51 2016 -0700
Added tests for interpreter panel --- nyx/panel/interpreter.py | 2 +- test/panel/__init__.py | 1 + test/panel/interpreter.py | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/nyx/panel/interpreter.py b/nyx/panel/interpreter.py index f6cd1c2..882ab01 100644 --- a/nyx/panel/interpreter.py +++ b/nyx/panel/interpreter.py @@ -102,7 +102,7 @@ class InterpreterPanel(panel.Panel): with patch('stem.interpreter.commands.code.InteractiveConsole.push') as console_push: response = self.interpreter.run_command(user_input) if console_push.called: - response = '\x1b[31;1m'' + user_input + '' isn't a recognized command\r\n' + response = '\x1b[31;1m'' + user_input + '' isn't a recognized command\n' if response: PROMPT_LINE.insert(len(PROMPT_LINE) - 1, format_input(user_input)) attrs = [] diff --git a/test/panel/__init__.py b/test/panel/__init__.py index 579da3f..4faf6e0 100644 --- a/test/panel/__init__.py +++ b/test/panel/__init__.py @@ -5,6 +5,7 @@ Unit tests for nyx's panel modules. __all__ = [ 'header', 'graph', + 'interpreter', 'log', 'connection', 'config', diff --git a/test/panel/interpreter.py b/test/panel/interpreter.py new file mode 100644 index 0000000..054aeff --- /dev/null +++ b/test/panel/interpreter.py @@ -0,0 +1,18 @@ +""" +Unit tests for nyx.panel.interpreter. +""" + +import unittest + +import nyx.panel.interpreter + + +class TestInterpreter(unittest.TestCase): + def test_ansi_to_output(self): + ansi_text = '\x1b[32;1mthis is some sample text' + output_line, attrs = nyx.panel.interpreter.ansi_to_output(ansi_text, []) + + self.assertEqual('this is some sample text', output_line[0][0]) + self.assertEqual('Green', output_line[0][1]) + self.assertEqual('Bold', output_line[0][2]) + self.assertEqual(['Green', 'Bold'], attrs)