Attempt at a test of completion of filepath after ~.

I'm not quite sure how this will behave on windows, and we can't really
create a tempdir (as we don't want to mess with path on home.

One possibility would be to mock/monkeypatch scandir, listdir and
os.path.expanduser or set $HOME in env; but I'm quite unsure we want to
go that route.
This commit is contained in:
Matthias Bussonnier
2019-08-23 18:26:11 +02:00
parent 9a3f41e63b
commit 5329f95096

View File

@@ -1,4 +1,5 @@
from os.path import join, sep as s
from os.path import join, sep as s, expanduser
import os
import sys
from textwrap import dedent
@@ -83,6 +84,14 @@ def test_loading_unicode_files_with_bad_global_charset(Script, monkeypatch, tmpd
line=2, column=4, path=filename2)
s.completions()
def test_complete_expanduser(Script):
possibilities = os.listdir(expanduser('~'))
non_dots = [p for p in possibilities if not p.startswith('.') and len(p) > 1]
item = non_dots[0]
line = "'~%s%s'" % (os.sep, item)
s = Script(line, line=1, column=len(line)-1)
assert item in [c.name for c in s.completions()]
def test_fake_subnodes(Script):
"""