##// END OF EJS Templates
Moved old wildcard tests into proper test suite.
Fernando Perez -
Show More
@@ -1,8 +1,18 b''
1 # -*- coding: UTF-8 -*-
1 """Some tests for the wildcard utilities."""
2 import sys, unittest
3 sys.path.append ('..')
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 class obj_t(object):
17 class obj_t(object):
8 pass
18 pass
@@ -34,6 +44,10 b' root.__ANKA.a=10'
34 root.__ANKA._a=20
44 root.__ANKA._a = 20
35 root.__ANKA.__a=20
45 root.__ANKA.__a = 20
36
46
47 #-----------------------------------------------------------------------------
48 # Test cases
49 #-----------------------------------------------------------------------------
50
37 class Tests (unittest.TestCase):
51 class Tests (unittest.TestCase):
38 def test_case(self):
52 def test_case(self):
39 ns=root.__dict__
53 ns=root.__dict__
@@ -46,7 +60,8 b' class Tests (unittest.TestCase):'
46 ]
60 ]
47 for pat,res in tests:
61 for pat,res in tests:
48 res.sort()
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 a.sort()
65 a.sort()
51 self.assertEqual(a,res)
66 self.assertEqual(a,res)
52
67
@@ -61,7 +76,8 b' class Tests (unittest.TestCase):'
61 ]
76 ]
62 for pat,res in tests:
77 for pat,res in tests:
63 res.sort()
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 a.sort()
81 a.sort()
66 self.assertEqual(a,res)
82 self.assertEqual(a,res)
67
83
@@ -70,14 +86,16 b' class Tests (unittest.TestCase):'
70 ns=root.__dict__
86 ns=root.__dict__
71 tests=[
87 tests=[
72 ("a*", ["abbot","abel","ABEL","active","arna",]),
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 ("_a*", []),
91 ("_a*", []),
75 ("_*anka", ["__anka","__ANKA",]),
92 ("_*anka", ["__anka","__ANKA",]),
76 ("_*a*", ["__anka","__ANKA",]),
93 ("_*a*", ["__anka","__ANKA",]),
77 ]
94 ]
78 for pat,res in tests:
95 for pat,res in tests:
79 res.sort()
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 a.sort()
99 a.sort()
82 self.assertEqual(a,res)
100 self.assertEqual(a,res)
83
101
@@ -85,16 +103,15 b' class Tests (unittest.TestCase):'
85 ns=root.__dict__
103 ns=root.__dict__
86 tests=[
104 tests=[
87 ("a*", ["abbot","abel","ABEL","active","arna",]),
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 ("_a*", ["_apan","_APAN"]),
108 ("_a*", ["_apan","_APAN"]),
90 ("_*anka", ["__anka","__ANKA",]),
109 ("_*anka", ["__anka","__ANKA",]),
91 ("_*a*", ["__anka","__ANKA","_apan","_APAN"]),
110 ("_*a*", ["__anka","__ANKA","_apan","_APAN"]),
92 ]
111 ]
93 for pat,res in tests:
112 for pat,res in tests:
94 res.sort()
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 a.sort()
116 a.sort()
97 self.assertEqual(a,res)
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