##// END OF EJS Templates
Add failing test for duplicate dirs in completions
Thomas Kluyver -
Show More
@@ -32,12 +32,16 b' class MockEvent(object):'
32 32 #-----------------------------------------------------------------------------
33 33 class Test_magic_run_completer(unittest.TestCase):
34 34 files = [u"aao.py", u"a.py", u"b.py", u"aao.txt"]
35 dirs = [u"adir", "bdir"]
35 36
36 37 def setUp(self):
37 38 self.BASETESTDIR = tempfile.mkdtemp()
38 39 for fil in self.files:
39 40 with open(join(self.BASETESTDIR, fil), "w") as sfile:
40 41 sfile.write("pass\n")
42 for d in self.dirs:
43 os.mkdir(join(self.BASETESTDIR, d))
44
41 45 self.oldpath = py3compat.getcwd()
42 46 os.chdir(self.BASETESTDIR)
43 47
@@ -51,7 +55,7 b' class Test_magic_run_completer(unittest.TestCase):'
51 55 event = MockEvent(u"%run a")
52 56 mockself = None
53 57 match = set(magic_run_completer(mockself, event))
54 self.assertEqual(match, set([u"a.py", u"aao.py"]))
58 self.assertEqual(match, {u"a.py", u"aao.py", u"adir/"})
55 59
56 60 def test_2(self):
57 61 """Test magic_run_completer, should match one alterntive
@@ -66,20 +70,20 b' class Test_magic_run_completer(unittest.TestCase):'
66 70 event = MockEvent(u'%run "a')
67 71 mockself = None
68 72 match = set(magic_run_completer(mockself, event))
69 self.assertEqual(match, set([u"a.py", u"aao.py"]))
73 self.assertEqual(match, {u"a.py", u"aao.py", u"adir/"})
70 74
71 75 def test_completion_more_args(self):
72 76 event = MockEvent(u'%run a.py ')
73 77 match = set(magic_run_completer(None, event))
74 self.assertEqual(match, set(self.files))
78 self.assertEqual(match, set(self.files + self.dirs))
75 79
76 80 def test_completion_in_dir(self):
77 81 # Github issue #3459
78 82 event = MockEvent(u'%run a.py {}'.format(join(self.BASETESTDIR, 'a')))
79 83 print(repr(event.line))
80 84 match = set(magic_run_completer(None, event))
81 self.assertEqual(match,
82 {join(self.BASETESTDIR, f) for f in (u'a.py', u'aao.py', u'aao.txt')})
85 self.assertEqual(match, {join(self.BASETESTDIR, f) for
86 f in (u'a.py', u'aao.py', u'aao.txt', u'adir')})
83 87
84 88 class Test_magic_run_completer_nonascii(unittest.TestCase):
85 89 @onlyif_unicode_paths
General Comments 0
You need to be logged in to leave comments. Login now