##// 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 -*-
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
@@ -34,6 +44,10 b' root.__ANKA.a=10'
34 44 root.__ANKA._a=20
35 45 root.__ANKA.__a=20
36 46
47 #-----------------------------------------------------------------------------
48 # Test cases
49 #-----------------------------------------------------------------------------
50
37 51 class Tests (unittest.TestCase):
38 52 def test_case(self):
39 53 ns=root.__dict__
@@ -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