##// END OF EJS Templates
use sets in test_completerlib, to be insensitive to ordering
MinRK -
Show More
@@ -1,69 +1,69 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Tests for completerlib.
3 3
4 4 """
5 5 from __future__ import absolute_import
6 6
7 7 #-----------------------------------------------------------------------------
8 8 # Imports
9 9 #-----------------------------------------------------------------------------
10 10
11 11 import os
12 12 import shutil
13 13 import sys
14 14 import tempfile
15 15 import unittest
16 16 from os.path import join
17 17
18 18 import nose.tools as nt
19 19 from nose import SkipTest
20 20
21 21 from IPython.core.completerlib import magic_run_completer
22 22 from IPython.testing import decorators as dec
23 23 from IPython.testing import tools as tt
24 24 from IPython.utils import py3compat
25 25
26 26
27 27 class MockEvent(object):
28 28 def __init__(self, line):
29 29 self.line = line
30 30
31 31 #-----------------------------------------------------------------------------
32 32 # Test functions begin
33 33 #-----------------------------------------------------------------------------
34 34 class Test_magic_run_completer(unittest.TestCase):
35 35 def setUp(self):
36 36 self.BASETESTDIR = tempfile.mkdtemp()
37 37 for fil in [u"aaø.py", u"a.py", u"b.py"]:
38 38 with open(join(self.BASETESTDIR, fil), "w") as sfile:
39 39 sfile.write("pass\n")
40 40 self.oldpath = os.getcwdu()
41 41 os.chdir(self.BASETESTDIR)
42 42
43 43 def tearDown(self):
44 44 os.chdir(self.oldpath)
45 45 shutil.rmtree(self.BASETESTDIR)
46 46
47 47 def test_1(self):
48 48 """Test magic_run_completer, should match two alterntives
49 49 """
50 50 event = MockEvent(u"%run a")
51 51 mockself = None
52 match = magic_run_completer(mockself, event)
53 self.assertEqual(match, [u"a.py", u"aaø.py"])
52 match = set(magic_run_completer(mockself, event))
53 self.assertEqual(match, set([u"a.py", u"aaø.py"]))
54 54
55 55 def test_2(self):
56 56 """Test magic_run_completer, should match one alterntive
57 57 """
58 58 event = MockEvent(u"%run aa")
59 59 mockself = None
60 match = magic_run_completer(mockself, event)
61 self.assertEqual(match, [u"aaø.py"])
60 match = set(magic_run_completer(mockself, event))
61 self.assertEqual(match, set([u"aaø.py"]))
62 62
63 63 def test_3(self):
64 """Test '%run "a<tab>' completion"""
64 """Test magic_run_completer with unterminated " """
65 65 event = MockEvent(u'%run "a')
66 66 mockself = None
67 match = magic_run_completer(mockself, event)
68 self.assertEqual(match, [u"a.py", u"aaø.py"])
67 match = set(magic_run_completer(mockself, event))
68 self.assertEqual(match, set([u"a.py", u"aaø.py"]))
69 69
General Comments 0
You need to be logged in to leave comments. Login now