##// END OF EJS Templates
Add doc strings to all functions
Jorgen Stenarson -
Show More
@@ -45,12 +45,20 b' test_file_path = split(abspath(__file__))[0]'
45 45
46 46
47 47 def setup():
48 """Setup testenvironment for the module:
49
50 - Adds dummy home dir tree
51 """
48 52 try:
49 53 os.makedirs("home_test_dir/_ipython")
50 54 except WindowsError:
51 55 pass #Or should we complain that the test directory already exists??
52 56
53 57 def teardown():
58 """Teardown testenvironment for the module:
59
60 - Remove dummy home dir tree
61 """
54 62 try:
55 63 os.removedirs("home_test_dir/_ipython")
56 64 except WindowsError:
@@ -58,6 +66,12 b' def teardown():'
58 66
59 67
60 68 def setup_environment():
69 """Setup testenvironment for some functions that are tested
70 in this module. In particular this functions stores attributes
71 and other things that we need to stub in some test functions.
72 This needs to be done on a function level and not module level because
73 each testfunction needs a pristine environment.
74 """
61 75 global oldstuff, platformstuff
62 76 oldstuff = (env.copy(), os.name, genutils.get_home_dir, IPython.__file__,)
63 77
@@ -68,6 +82,8 b' def setup_environment():'
68 82 del env['IPYTHONDIR']
69 83
70 84 def teardown_environment():
85 """Restore things that were remebered by the setup_environment function
86 """
71 87 (oldenv, os.name, genutils.get_home_dir, IPython.__file__,) = oldstuff
72 88 for key in env.keys():
73 89 if key not in oldenv:
@@ -78,7 +94,8 b' def teardown_environment():'
78 94 if os.name == 'nt':
79 95 (wreg.OpenKey, wreg.QueryValueEx,) = platformstuff
80 96
81 with_enivronment = with_setup(setup_environment, teardown_environment)
97 # Build decorator that uses the setup_environment/setup_environment
98 with_enivronment = with_setup(setup_environment, setup_environment)
82 99
83 100
84 101 #
@@ -183,7 +200,7 b' def test_get_home_dir_7():'
183 200
184 201 @with_enivronment
185 202 def test_get_ipython_dir_1():
186 """2 Testcase to see if we can call get_ipython_dir without Exceptions."""
203 """test_get_ipython_dir_1, Testcase to see if we can call get_ipython_dir without Exceptions."""
187 204 env['IPYTHONDIR'] = "someplace/.ipython"
188 205 ipdir = genutils.get_ipython_dir()
189 206 nt.assert_equal(ipdir, os.path.abspath("someplace/.ipython"))
@@ -191,7 +208,7 b' def test_get_ipython_dir_1():'
191 208
192 209 @with_enivronment
193 210 def test_get_ipython_dir_2():
194 """3 Testcase to see if we can call get_ipython_dir without Exceptions."""
211 """test_get_ipython_dir_2, Testcase to see if we can call get_ipython_dir without Exceptions."""
195 212 genutils.get_home_dir = lambda : "someplace"
196 213 os.name = "posix"
197 214 ipdir = genutils.get_ipython_dir()
@@ -199,7 +216,7 b' def test_get_ipython_dir_2():'
199 216
200 217 @with_enivronment
201 218 def test_get_ipython_dir_3():
202 """4 Testcase to see if we can call get_ipython_dir without Exceptions."""
219 """test_get_ipython_dir_3, Testcase to see if we can call get_ipython_dir without Exceptions."""
203 220 genutils.get_home_dir = lambda : "someplace"
204 221 os.name = "nt"
205 222 ipdir = genutils.get_ipython_dir()
@@ -221,6 +238,8 b' def test_get_security_dir():'
221 238 #
222 239
223 240 def test_popkey_1():
241 """test_popkey_1, Basic usage test of popkey
242 """
224 243 dct = dict(a=1, b=2, c=3)
225 244 nt.assert_equal(genutils.popkey(dct, "a"), 1)
226 245 nt.assert_equal(dct, dict(b=2, c=3))
@@ -230,10 +249,16 b' def test_popkey_1():'
230 249 nt.assert_equal(dct, dict())
231 250
232 251 def test_popkey_2():
252 """test_popkey_2, Test to see that popkey of non occuring keys
253 generates a KeyError exception
254 """
233 255 dct = dict(a=1, b=2, c=3)
234 256 nt.assert_raises(KeyError, genutils.popkey, dct, "d")
235 257
236 258 def test_popkey_3():
259 """test_popkey_3, Tests to see that popkey calls returns the correct value
260 and that the key/value was removed from the dict.
261 """
237 262 dct = dict(a=1, b=2, c=3)
238 263 nt.assert_equal(genutils.popkey(dct, "A", 13), 13)
239 264 nt.assert_equal(dct, dict(a=1, b=2, c=3))
General Comments 0
You need to be logged in to leave comments. Login now