Show More
@@ -15,6 +15,7 b' from __future__ import print_function' | |||||
15 |
|
15 | |||
16 | # Stdlib imports |
|
16 | # Stdlib imports | |
17 | import os |
|
17 | import os | |
|
18 | import re | |||
18 |
|
19 | |||
19 | # Third-party imports |
|
20 | # Third-party imports | |
20 | import nose.tools as nt |
|
21 | import nose.tools as nt | |
@@ -44,15 +45,24 b' ip = get_ipython()' | |||||
44 | # defined, if any code is inserted above, the following line will need to be |
|
45 | # defined, if any code is inserted above, the following line will need to be | |
45 | # updated. Do NOT insert any whitespace between the next line and the function |
|
46 | # updated. Do NOT insert any whitespace between the next line and the function | |
46 | # definition below. |
|
47 | # definition below. | |
47 |
THIS_LINE_NUMBER = 4 |
|
48 | THIS_LINE_NUMBER = 48 # Put here the actual number of this line | |
48 | def test_find_source_lines(): |
|
49 | def test_find_source_lines(): | |
49 | nt.assert_equal(oinspect.find_source_lines(test_find_source_lines), |
|
50 | nt.assert_equal(oinspect.find_source_lines(test_find_source_lines), | |
50 | THIS_LINE_NUMBER+1) |
|
51 | THIS_LINE_NUMBER+1) | |
51 |
|
52 | |||
52 |
|
53 | |||
|
54 | # A couple of utilities to ensure these tests work the same from a source or a | |||
|
55 | # binary install | |||
|
56 | def pyfile(fname): | |||
|
57 | return re.sub('.py[co]$', '.py', fname) | |||
|
58 | ||||
|
59 | ||||
|
60 | def match_pyfiles(f1, f2): | |||
|
61 | nt.assert_equal(pyfile(f1), pyfile(f2)) | |||
|
62 | ||||
|
63 | ||||
53 | def test_find_file(): |
|
64 | def test_find_file(): | |
54 |
|
|
65 | match_pyfiles(oinspect.find_file(test_find_file), os.path.abspath(__file__)) | |
55 | os.path.abspath(__file__)) |
|
|||
56 |
|
66 | |||
57 |
|
67 | |||
58 | def test_find_file_decorated1(): |
|
68 | def test_find_file_decorated1(): | |
@@ -67,8 +77,7 b' def test_find_file_decorated1():' | |||||
67 | def f(x): |
|
77 | def f(x): | |
68 | "My docstring" |
|
78 | "My docstring" | |
69 |
|
79 | |||
70 | nt.assert_equal(oinspect.find_file(f), |
|
80 | match_pyfiles(oinspect.find_file(f), os.path.abspath(__file__)) | |
71 | os.path.abspath(__file__)) |
|
|||
72 | nt.assert_equal(f.__doc__, "My docstring") |
|
81 | nt.assert_equal(f.__doc__, "My docstring") | |
73 |
|
82 | |||
74 |
|
83 | |||
@@ -82,8 +91,7 b' def test_find_file_decorated2():' | |||||
82 | def f(x): |
|
91 | def f(x): | |
83 | "My docstring 2" |
|
92 | "My docstring 2" | |
84 |
|
93 | |||
85 | nt.assert_equal(oinspect.find_file(f), |
|
94 | match_pyfiles(oinspect.find_file(f), os.path.abspath(__file__)) | |
86 | os.path.abspath(__file__)) |
|
|||
87 | nt.assert_equal(f.__doc__, "My docstring 2") |
|
95 | nt.assert_equal(f.__doc__, "My docstring 2") | |
88 |
|
96 | |||
89 |
|
97 |
General Comments 0
You need to be logged in to leave comments.
Login now