From f5f4be49c2ea6e1d24d8a2cbf0260df238016a06 2010-07-26 09:08:15 From: Fernando Perez Date: 2010-07-26 09:08:15 Subject: [PATCH] Moved old wildcard tests into proper test suite. --- diff --git a/test/test_wildcard.py b/IPython/utils/tests/test_wildcard.py similarity index 57% rename from test/test_wildcard.py rename to IPython/utils/tests/test_wildcard.py index 1e0ee6c..d2bc4df 100644 --- a/test/test_wildcard.py +++ b/IPython/utils/tests/test_wildcard.py @@ -1,38 +1,52 @@ -# -*- coding: UTF-8 -*- -import sys, unittest -sys.path.append ('..') +"""Some tests for the wildcard utilities.""" -from IPython import wildcard +#----------------------------------------------------------------------------- +# Library imports +#----------------------------------------------------------------------------- +# Stdlib +import sys +import unittest + +# Our own +from IPython.utils import wildcard + +#----------------------------------------------------------------------------- +# Globals for test +#----------------------------------------------------------------------------- class obj_t(object): pass -root=obj_t() -l=["arna","abel","ABEL","active","bob","bark","abbot"] -q=["kate","loop","arne","vito","lucifer","koppel"] +root = obj_t() +l = ["arna","abel","ABEL","active","bob","bark","abbot"] +q = ["kate","loop","arne","vito","lucifer","koppel"] for x in l: - o=obj_t() + o = obj_t() setattr(root,x,o) for y in q: - p=obj_t() + p = obj_t() setattr(o,y,p) -root._apan=obj_t() -root._apan.a=10 -root._apan._a=20 -root._apan.__a=20 -root.__anka=obj_t() -root.__anka.a=10 -root.__anka._a=20 -root.__anka.__a=20 +root._apan = obj_t() +root._apan.a = 10 +root._apan._a = 20 +root._apan.__a = 20 +root.__anka = obj_t() +root.__anka.a = 10 +root.__anka._a = 20 +root.__anka.__a = 20 + +root._APAN = obj_t() +root._APAN.a = 10 +root._APAN._a = 20 +root._APAN.__a = 20 +root.__ANKA = obj_t() +root.__ANKA.a = 10 +root.__ANKA._a = 20 +root.__ANKA.__a = 20 -root._APAN=obj_t() -root._APAN.a=10 -root._APAN._a=20 -root._APAN.__a=20 -root.__ANKA=obj_t() -root.__ANKA.a=10 -root.__ANKA._a=20 -root.__ANKA.__a=20 +#----------------------------------------------------------------------------- +# Test cases +#----------------------------------------------------------------------------- class Tests (unittest.TestCase): def test_case(self): @@ -46,7 +60,8 @@ class Tests (unittest.TestCase): ] for pat,res in tests: res.sort() - a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,show_all=False).keys() + a=wildcard.list_namespace(ns,"all",pat,ignore_case=False, + show_all=False).keys() a.sort() self.assertEqual(a,res) @@ -61,7 +76,8 @@ class Tests (unittest.TestCase): ] for pat,res in tests: res.sort() - a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,show_all=True).keys() + a=wildcard.list_namespace(ns,"all",pat,ignore_case=False, + show_all=True).keys() a.sort() self.assertEqual(a,res) @@ -70,14 +86,16 @@ class Tests (unittest.TestCase): ns=root.__dict__ tests=[ ("a*", ["abbot","abel","ABEL","active","arna",]), - ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop","ABEL.koppel","ABEL.loop",]), + ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop", + "ABEL.koppel","ABEL.loop",]), ("_a*", []), ("_*anka", ["__anka","__ANKA",]), ("_*a*", ["__anka","__ANKA",]), ] for pat,res in tests: res.sort() - a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,show_all=False).keys() + a=wildcard.list_namespace(ns,"all",pat,ignore_case=True, + show_all=False).keys() a.sort() self.assertEqual(a,res) @@ -85,16 +103,15 @@ class Tests (unittest.TestCase): ns=root.__dict__ tests=[ ("a*", ["abbot","abel","ABEL","active","arna",]), - ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop","ABEL.koppel","ABEL.loop",]), + ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop", + "ABEL.koppel","ABEL.loop",]), ("_a*", ["_apan","_APAN"]), ("_*anka", ["__anka","__ANKA",]), ("_*a*", ["__anka","__ANKA","_apan","_APAN"]), ] for pat,res in tests: res.sort() - a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,show_all=True).keys() + a=wildcard.list_namespace(ns,"all",pat,ignore_case=True, + show_all=True).keys() a.sort() self.assertEqual(a,res) - -if __name__ == '__main__': - unittest.main() \ No newline at end of file