MCPcopy Create free account
hub / github.com/ipython/ipython / test_quoted_file_completions

Method test_quoted_file_completions

tests/test_completer.py:439–464  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

437 self.assertTrue(comp.issubset(set(c)), msg=f"completes in {name}")
438
439 def test_quoted_file_completions(self):
440 ip = get_ipython()
441
442 def _(text):
443 return ip.Completer._complete(
444 cursor_line=0, cursor_pos=len(text), full_text=text
445 )["IPCompleter.file_matcher"]["completions"]
446
447 with TemporaryWorkingDirectory():
448 name = "foo'bar"
449 open(name, "w", encoding="utf-8").close()
450
451 # Don't escape Windows
452 escaped = name if sys.platform == "win32" else "foo\\'bar"
453
454 # Single quote matches embedded single quote
455 c = _("open('foo")[0]
456 self.assertEqual(c.text, escaped)
457
458 # Double quote requires no escape
459 c = _('open("foo')[0]
460 self.assertEqual(c.text, name)
461
462 # No quote requires an escape
463 c = _("%ls foo")[0]
464 self.assertEqual(c.text, escaped)
465
466 @pytest.mark.xfail(
467 sys.version_info.releaselevel in ("alpha",),

Callers

nothing calls this directly

Calls 3

get_ipythonFunction · 0.90
closeMethod · 0.45

Tested by

no test coverage detected