[Python-checkins] r78147 - python/branches/release26-maint/Lib/test/test_readline.py
ronald.oussoren
python-checkins at python.org
Thu Feb 11 14:03:15 CET 2010
Author: ronald.oussoren
Date: Thu Feb 11 14:03:15 2010
New Revision: 78147
Log:
Add testcase for readline-using-libedit on OSX
Added:
python/branches/release26-maint/Lib/test/test_readline.py (contents, props changed)
Added: python/branches/release26-maint/Lib/test/test_readline.py
==============================================================================
--- (empty file)
+++ python/branches/release26-maint/Lib/test/test_readline.py Thu Feb 11 14:03:15 2010
@@ -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()
More information about the Python-checkins
mailing list