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