diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2010-02-11 13:03:15 (GMT) |
---|---|---|
committer | Ronald Oussoren <ronaldoussoren@mac.com> | 2010-02-11 13:03:15 (GMT) |
commit | a3236133d9357d7c8985cb003745255d69cad465 (patch) | |
tree | cca668f041dce430f7e7c52f790c1f4c1355bf5a | |
parent | b92a305d2ad46cc7ba918da8d21531677d48862c (diff) | |
download | cpython-a3236133d9357d7c8985cb003745255d69cad465.zip cpython-a3236133d9357d7c8985cb003745255d69cad465.tar.gz cpython-a3236133d9357d7c8985cb003745255d69cad465.tar.bz2 |
Add testcase for readline-using-libedit on OSX
-rw-r--r-- | Lib/test/test_readline.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Lib/test/test_readline.py b/Lib/test/test_readline.py new file mode 100644 index 0000000..a2210d4 --- /dev/null +++ b/Lib/test/test_readline.py @@ -0,0 +1,42 @@ +""" +Very minimal unittests for parts of the readline module. + +These tests were added to check that the libedit emulation on OSX and +the "real" readline have the same interface for history manipulation. That's +why the tests cover only a small subset of the interface. +""" +import unittest +from test.test_support import run_unittest + +import readline + +class TestHistoryManipulation (unittest.TestCase): + def testHistoryUpdates(self): + readline.clear_history() + + readline.add_history("first line") + readline.add_history("second line") + + self.assertEqual(readline.get_history_item(0), None) + self.assertEqual(readline.get_history_item(1), "first line") + self.assertEqual(readline.get_history_item(2), "second line") + + readline.replace_history_item(0, "replaced line") + self.assertEqual(readline.get_history_item(0), None) + self.assertEqual(readline.get_history_item(1), "replaced line") + self.assertEqual(readline.get_history_item(2), "second line") + + self.assertEqual(readline.get_current_history_length(), 2) + + readline.remove_history_item(0) + self.assertEqual(readline.get_history_item(0), None) + self.assertEqual(readline.get_history_item(1), "second line") + + self.assertEqual(readline.get_current_history_length(), 1) + + +def test_main(): + run_unittest(TestHistoryManipulation) + +if __name__ == "__main__": + test_main() |