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') 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.", path=filename2) s.complete(line=2, column=4)
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) expected_name = item.name if item.is_dir(): expected_name += os.path.sep assert expected_name in [c.name for c in s.complete(column=len(line)-1)]