MCPcopy Index your code
hub / github.com/bpython/bpython / test_parameter_advanced_on_class

Method test_parameter_advanced_on_class

bpython/test/test_repl.py:512–544  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
547if __name__ == "__main__":

Callers

nothing calls this directly

Calls 4

set_input_lineMethod · 0.95
FakeReplClass · 0.85
pushMethod · 0.45
completeMethod · 0.45

Tested by

no test coverage detected