(self)
| 510 | ) |
| 511 | |
| 512 | def test_parameter_advanced_on_class(self): |
| 513 | self.repl = FakeRepl( |
| 514 | {"autocomplete_mode": autocomplete.AutocompleteModes.SIMPLE} |
| 515 | ) |
| 516 | self.set_input_line("TestCls(app") |
| 517 | |
| 518 | code = """ |
| 519 | import inspect |
| 520 | |
| 521 | class TestCls: |
| 522 | # A class with boring __init__ typing |
| 523 | def __init__(self, *args, **kwargs): |
| 524 | pass |
| 525 | # But that uses super exotic typings recognized by inspect.signature |
| 526 | __signature__ = inspect.Signature([ |
| 527 | inspect.Parameter("apple", inspect.Parameter.POSITIONAL_ONLY), |
| 528 | inspect.Parameter("apple2", inspect.Parameter.KEYWORD_ONLY), |
| 529 | inspect.Parameter("pinetree", inspect.Parameter.KEYWORD_ONLY), |
| 530 | ]) |
| 531 | """ |
| 532 | code = [x[8:] for x in code.split("\n")] |
| 533 | for line in code: |
| 534 | self.repl.push(line) |
| 535 | |
| 536 | with mock.patch( |
| 537 | "bpython.inspection.inspect.getsourcelines", |
| 538 | return_value=(code, None), |
| 539 | ): |
| 540 | self.assertTrue(self.repl.complete()) |
| 541 | self.assertTrue(hasattr(self.repl.matches_iter, "matches")) |
| 542 | self.assertEqual( |
| 543 | self.repl.matches_iter.matches, ["apple2=", "apple="] |
| 544 | ) |
| 545 | |
| 546 | |
| 547 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected