##// END OF EJS Templates
Moved old wildcard tests into proper test suite.
Fernando Perez -
Show More
@@ -1,38 +1,52 b''
1 # -*- coding: UTF-8 -*-
2 import sys, unittest
3 sys.path.append ('..')
1 """Some tests for the wildcard utilities."""
4 2
5 from IPython import wildcard
3 #-----------------------------------------------------------------------------
4 # Library imports
5 #-----------------------------------------------------------------------------
6 # Stdlib
7 import sys
8 import unittest
9
10 # Our own
11 from IPython.utils import wildcard
12
13 #-----------------------------------------------------------------------------
14 # Globals for test
15 #-----------------------------------------------------------------------------
6 16
7 17 class obj_t(object):
8 18 pass
9 19
10 root=obj_t()
11 l=["arna","abel","ABEL","active","bob","bark","abbot"]
12 q=["kate","loop","arne","vito","lucifer","koppel"]
20 root = obj_t()
21 l = ["arna","abel","ABEL","active","bob","bark","abbot"]
22 q = ["kate","loop","arne","vito","lucifer","koppel"]
13 23 for x in l:
14 o=obj_t()
24 o = obj_t()
15 25 setattr(root,x,o)
16 26 for y in q:
17 p=obj_t()
27 p = obj_t()
18 28 setattr(o,y,p)
19 root._apan=obj_t()
20 root._apan.a=10
21 root._apan._a=20
22 root._apan.__a=20
23 root.__anka=obj_t()
24 root.__anka.a=10
25 root.__anka._a=20
26 root.__anka.__a=20
29 root._apan = obj_t()
30 root._apan.a = 10
31 root._apan._a = 20
32 root._apan.__a = 20
33 root.__anka = obj_t()
34 root.__anka.a = 10
35 root.__anka._a = 20
36 root.__anka.__a = 20
37
38 root._APAN = obj_t()
39 root._APAN.a = 10
40 root._APAN._a = 20
41 root._APAN.__a = 20
42 root.__ANKA = obj_t()
43 root.__ANKA.a = 10
44 root.__ANKA._a = 20
45 root.__ANKA.__a = 20
27 46
28 root._APAN=obj_t()
29 root._APAN.a=10
30 root._APAN._a=20
31 root._APAN.__a=20
32 root.__ANKA=obj_t()
33 root.__ANKA.a=10
34 root.__ANKA._a=20
35 root.__ANKA.__a=20
47 #-----------------------------------------------------------------------------
48 # Test cases
49 #-----------------------------------------------------------------------------
36 50
37 51 class Tests (unittest.TestCase):
38 52 def test_case(self):
@@ -46,7 +60,8 b' class Tests (unittest.TestCase):'
46 60 ]
47 61 for pat,res in tests:
48 62 res.sort()
49 a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,show_all=False).keys()
63 a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,
64 show_all=False).keys()
50 65 a.sort()
51 66 self.assertEqual(a,res)
52 67
@@ -61,7 +76,8 b' class Tests (unittest.TestCase):'
61 76 ]
62 77 for pat,res in tests:
63 78 res.sort()
64 a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,show_all=True).keys()
79 a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,
80 show_all=True).keys()
65 81 a.sort()
66 82 self.assertEqual(a,res)
67 83
@@ -70,14 +86,16 b' class Tests (unittest.TestCase):'
70 86 ns=root.__dict__
71 87 tests=[
72 88 ("a*", ["abbot","abel","ABEL","active","arna",]),
73 ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop","ABEL.koppel","ABEL.loop",]),
89 ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop",
90 "ABEL.koppel","ABEL.loop",]),
74 91 ("_a*", []),
75 92 ("_*anka", ["__anka","__ANKA",]),
76 93 ("_*a*", ["__anka","__ANKA",]),
77 94 ]
78 95 for pat,res in tests:
79 96 res.sort()
80 a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,show_all=False).keys()
97 a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,
98 show_all=False).keys()
81 99 a.sort()
82 100 self.assertEqual(a,res)
83 101
@@ -85,16 +103,15 b' class Tests (unittest.TestCase):'
85 103 ns=root.__dict__
86 104 tests=[
87 105 ("a*", ["abbot","abel","ABEL","active","arna",]),
88 ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop","ABEL.koppel","ABEL.loop",]),
106 ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop",
107 "ABEL.koppel","ABEL.loop",]),
89 108 ("_a*", ["_apan","_APAN"]),
90 109 ("_*anka", ["__anka","__ANKA",]),
91 110 ("_*a*", ["__anka","__ANKA","_apan","_APAN"]),
92 111 ]
93 112 for pat,res in tests:
94 113 res.sort()
95 a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,show_all=True).keys()
114 a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,
115 show_all=True).keys()
96 116 a.sort()
97 117 self.assertEqual(a,res)
98
99 if __name__ == '__main__':
100 unittest.main() No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now