def test_loading_unicode_files_with_bad_global_charset(Script, monkeypatch, tmpdir): dirname = str(tmpdir.mkdir('jedi-test')) filename1 = join(dirname, 'test1.py') filename2 = join(dirname, 'test2.py') if sys.version_info < (3, 0): data = "# coding: latin-1\nfoo = 'm\xf6p'\n" else: data = "# coding: latin-1\nfoo = 'm\xf6p'\n".encode("latin-1") with open(filename1, "wb") as f: f.write(data) s = Script("from test1 import foo\nfoo.", line=2, column=4, path=filename2) s.completions()
def test_complete_expanduser(Script): possibilities = scandir(expanduser('~')) non_dots = [ p for p in possibilities if not p.name.startswith('.') and len(p.name) > 1 ] item = non_dots[0] line = "'~%s%s'" % (os.sep, item.name) s = Script(line, line=1, column=len(line) - 1) expected_name = item.name if item.is_dir(): expected_name += os.path.sep assert expected_name in [c.name for c in s.completions()]