|
| 1 | +import os |
1 | 2 | import unittest |
2 | 3 | from itertools import islice |
3 | 4 |
|
4 | | -from bpython import repl |
| 5 | +from bpython import config, repl |
5 | 6 |
|
6 | 7 |
|
7 | 8 | class TestHistory(unittest.TestCase): |
@@ -129,6 +130,34 @@ def test_update(self): |
129 | 130 | self.assertNotEqual(list(slice), self.matches) |
130 | 131 | self.assertEqual(list(newslice), newmatches) |
131 | 132 |
|
| 133 | +class TestRepl(repl.Repl): |
| 134 | + def __init__(self): |
| 135 | + config_struct = config.Struct() |
| 136 | + config.loadini(config_struct, os.devnull) |
| 137 | + repl.Repl.__init__(self, repl.Interpreter(), config_struct) |
| 138 | + self.input_line = "" |
| 139 | + |
| 140 | + def current_line(self): |
| 141 | + return self.input_line |
| 142 | + |
| 143 | +class TestArgspec(unittest.TestCase): |
| 144 | + def setUp(self): |
| 145 | + self.repl = TestRepl() |
| 146 | + self.repl.push("def spam(a, b, c):\n", False) |
| 147 | + self.repl.push(" pass\n", False) |
| 148 | + self.repl.push("\n", False) |
| 149 | + |
| 150 | + def setInputLine(self, line): |
| 151 | + """Set current input line of the test REPL.""" |
| 152 | + self.repl.input_line = line |
| 153 | + |
| 154 | + def test_lambda_position(self): |
| 155 | + self.setInputLine("spam(lambda a, b: 1, ") |
| 156 | + self.assertTrue(self.repl.get_args()) |
| 157 | + self.assertTrue(self.repl.argspec) |
| 158 | + # Argument position |
| 159 | + self.assertEqual(self.repl.argspec[3], 1) |
| 160 | + |
132 | 161 |
|
133 | 162 | if __name__ == '__main__': |
134 | 163 | unittest.main() |
0 commit comments