##// END OF EJS Templates
Use IPython parameterized testing
Jonathan Frederic -
Show More
@@ -1,88 +1,84 b''
1 1 """
2 2 Module with tests for ansi filters
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 from IPython.testing import decorators as dec
18 17 from IPython.utils.coloransi import TermColors
19 18
20 19 from ...tests.base import TestsBase
21 20 from ..ansi import strip_ansi, ansi2html, ansi2latex
22 21
23 22
24 23 #-----------------------------------------------------------------------------
25 24 # Class
26 25 #-----------------------------------------------------------------------------
27 26
28 27 class TestAnsi(TestsBase):
29 28 """Contains test functions for ansi.py"""
30 29
31 @dec.parametric
32 30 def test_strip_ansi(self):
33 31 """strip_ansi test"""
34 32 correct_outputs = {
35 33 '%s%s%s' % (TermColors.Green, TermColors.White, TermColors.Red) : '',
36 34 'hello%s' % TermColors.Blue: 'hello',
37 35 'he%s%sllo' % (TermColors.Yellow, TermColors.Cyan) : 'hello',
38 36 '%shello' % TermColors.Blue : 'hello',
39 37 '{0}h{0}e{0}l{0}l{0}o{0}'.format(TermColors.Red) : 'hello',
40 38 'hel%slo' % TermColors.Green : 'hello',
41 39 'hello' : 'hello'}
42 40
43 41 for inval, outval in correct_outputs.items():
44 yield self._try_strip_ansi, inval, outval
42 yield self._try_strip_ansi(inval, outval)
45 43
46 44
47 45 def _try_strip_ansi(self, inval, outval):
48 self.assert_equal(outval, strip_ansi(inval))
46 self.assertEqual(outval, strip_ansi(inval))
49 47
50 48
51 @dec.parametric
52 49 def test_ansi2html(self):
53 50 """ansi2html test"""
54 51 correct_outputs = {
55 52 '%s' % (TermColors.Red) : '<span class="ansired"></span>',
56 53 'hello%s' % TermColors.Blue: 'hello<span class="ansiblue"></span>',
57 54 'he%s%sllo' % (TermColors.Green, TermColors.Cyan) : 'he<span class="ansigreen"></span><span class="ansicyan">llo</span>',
58 55 '%shello' % TermColors.Yellow : '<span class="ansiyellow">hello</span>',
59 56 '{0}h{0}e{0}l{0}l{0}o{0}'.format(TermColors.White) : '<span class="ansigrey">h</span><span class="ansigrey">e</span><span class="ansigrey">l</span><span class="ansigrey">l</span><span class="ansigrey">o</span><span class="ansigrey"></span>',
60 57 'hel%slo' % TermColors.Green : 'hel<span class="ansigreen">lo</span>',
61 58 'hello' : 'hello'}
62 59
63 60 for inval, outval in correct_outputs.items():
64 yield self._try_ansi2html, inval, outval
61 yield self._try_ansi2html(inval, outval)
65 62
66 63
67 64 def _try_ansi2html(self, inval, outval):
68 65 self.fuzzy_compare(outval, ansi2html(inval))
69 66
70 67
71 @dec.parametric
72 68 def test_ansi2latex(self):
73 69 """ansi2latex test"""
74 70 correct_outputs = {
75 71 '%s' % (TermColors.Red) : r'\red{}',
76 72 'hello%s' % TermColors.Blue: r'hello\blue{}',
77 73 'he%s%sllo' % (TermColors.Green, TermColors.Cyan) : r'he\green{}\cyan{llo}',
78 74 '%shello' % TermColors.Yellow : r'\yellow{hello}',
79 75 '{0}h{0}e{0}l{0}l{0}o{0}'.format(TermColors.White) : r'\white{h}\white{e}\white{l}\white{l}\white{o}\white{}',
80 76 'hel%slo' % TermColors.Green : r'hel\green{lo}',
81 77 'hello' : 'hello'}
82 78
83 79 for inval, outval in correct_outputs.items():
84 yield self._try_ansi2latex, inval, outval
80 yield self._try_ansi2latex(inval, outval)
85 81
86 82
87 83 def _try_ansi2latex(self, inval, outval):
88 84 self.fuzzy_compare(outval, ansi2latex(inval), case_sensitive=True)
@@ -1,46 +1,46 b''
1 1 """
2 2 Module with tests for DataTypeFilter
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17
18 18 from ...tests.base import TestsBase
19 19 from ..datatypefilter import DataTypeFilter
20 20
21 21
22 22 #-----------------------------------------------------------------------------
23 23 # Class
24 24 #-----------------------------------------------------------------------------
25 25
26 26 class TestDataTypeFilter(TestsBase):
27 27 """Contains test functions for datatypefilter.py"""
28 28
29 29
30 30 def test_constructor(self):
31 31 """Can an instance of a DataTypeFilter be created?"""
32 32 DataTypeFilter()
33 33
34 34
35 35 def test_junk_types(self):
36 36 """Can the DataTypeFilter pickout a useful type from a list of junk types?"""
37 37 filter = DataTypeFilter()
38 38 assert "png" in filter(["hair", "water", "png", "rock"])
39 39 assert "pdf" in filter(["pdf", "hair", "water", "png", "rock"])
40 self.assert_equals(filter(["hair", "water", "rock"]), [])
40 self.assertEqual(filter(["hair", "water", "rock"]), [])
41 41
42 42
43 43 def test_null(self):
44 44 """Will the DataTypeFilter fail if no types are passed in?"""
45 45 filter = DataTypeFilter()
46 self.assert_equals(filter([]), [])
46 self.assertEqual(filter([]), [])
@@ -1,69 +1,65 b''
1 1 """
2 2 Module with tests for Highlight
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 from IPython.testing import decorators as dec
18
19 17 from ...tests.base import TestsBase
20 18 from ..highlight import highlight2html, highlight2latex
21 19
22 20
23 21 #-----------------------------------------------------------------------------
24 22 # Class
25 23 #-----------------------------------------------------------------------------
26 24
27 25 class TestHighlight(TestsBase):
28 26 """Contains test functions for highlight.py"""
29 27
30 28 #Hello world test, magics test, blank string test
31 29 tests = [
32 30 """
33 31 #Hello World Example
34 32
35 33 def say(text):
36 34 print(text)
37 35
38 36 say('Hello World!')
39 37 """,
40 38 """
41 39 %%pylab
42 40 plot(x,y, 'r')
43 41 """
44 42 ]
45 43
46 44 tokens = [
47 45 ['Hello World Example', 'say', 'text', 'print', 'def'],
48 46 ['pylab', 'plot']]
49 47
50 48
51 @dec.parametric
52 49 def test_highlight2html(self):
53 50 """highlight2html test"""
54 51 for index, test in enumerate(self.tests):
55 yield self._try_highlight, highlight2html, test, self.tokens[index]
52 yield self._try_highlight(highlight2html, test, self.tokens[index])
56 53
57 54
58 @dec.parametric
59 55 def test_highlight2latex(self):
60 56 """highlight2latex test"""
61 57 for index, test in enumerate(self.tests):
62 yield self._try_highlight, highlight2latex, test, self.tokens[index]
58 yield self._try_highlight(highlight2latex, test, self.tokens[index])
63 59
64 60
65 61 def _try_highlight(self, method, test, tokens):
66 62 """Try highlighting source, look for key tokens"""
67 63 results = method(test)
68 64 for token in tokens:
69 65 assert token in results
@@ -1,69 +1,65 b''
1 1 """
2 2 Module with tests for Latex
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 from IPython.testing import decorators as dec
18
19 17 from ...tests.base import TestsBase
20 18 from ..latex import escape_latex, strip_math_space
21 19
22 20
23 21 #-----------------------------------------------------------------------------
24 22 # Class
25 23 #-----------------------------------------------------------------------------
26 24
27 25 class TestLatex(TestsBase):
28 26
29 27
30 @dec.parametric
31 28 def test_escape_latex(self):
32 29 """escape_latex test"""
33 30 tests = [
34 31 (r'How are \you doing today?', r'How are \textbackslashyou doing today?'),
35 32 (r'\escapechar=`\A\catcode`\|=0 |string|foo', r'\textbackslashescapechar=`\textbackslashA\textbackslashcatcode`\textbackslash|=0 |string|foo'),
36 33 (r'# $ % & ~ _ ^ \ { }',r'\# \$ \% \& \~{} \_ \^{} \textbackslash \{ \}'),
37 34 ('','')]
38 35
39 36 for test in tests:
40 yield self._try_escape_latex, test[0], test[1]
37 yield self._try_escape_latex(test[0], test[1])
41 38
42 39
43 40 def _try_escape_latex(self, test, result):
44 41 """Try to remove latex from string"""
45 self.assert_equal(escape_latex(test), result)
42 self.assertEqual(escape_latex(test), result)
46 43
47 44
48 @dec.parametric
49 45 def test_strip_math_space(self):
50 46 """strip_math_space test"""
51 47 tests = [
52 48 ('$e$','$e$'),
53 49 ('$ e $','$e$'),
54 50 ('xxx$e^i$yyy','xxx$e^i$yyy'),
55 51 ('xxx$ e^i $yyy','xxx$e^i$yyy'),
56 52 ('xxx$e^i $yyy','xxx$e^i$yyy'),
57 53 ('xxx$ e^i$yyy','xxx$e^i$yyy'),
58 54 ('\$ e $ e $','\$ e $e$'),
59 55 ('','')]
60 56
61 57 for test in tests:
62 yield self._try_strip_math_space, test[0], test[1]
58 yield self._try_strip_math_space(test[0], test[1])
63 59
64 60
65 61 def _try_strip_math_space(self, test, result):
66 62 """
67 63 Try to remove spaces between dollar symbols and contents correctly
68 64 """
69 self.assert_equal(strip_math_space(test), result)
65 self.assertEqual(strip_math_space(test), result)
@@ -1,96 +1,93 b''
1 1
2 2 """
3 3 Module with tests for Markdown
4 4 """
5 5
6 6 #-----------------------------------------------------------------------------
7 7 # Copyright (c) 2013, the IPython Development Team.
8 8 #
9 9 # Distributed under the terms of the Modified BSD License.
10 10 #
11 11 # The full license is in the file COPYING.txt, distributed with this software.
12 12 #-----------------------------------------------------------------------------
13 13
14 14 #-----------------------------------------------------------------------------
15 15 # Imports
16 16 #-----------------------------------------------------------------------------
17 17
18 18 from copy import copy
19 19
20 20 from IPython.utils.py3compat import string_types
21 21 from IPython.testing import decorators as dec
22 22
23 23 from ...tests.base import TestsBase
24 24 from ..markdown import markdown2latex, markdown2html, markdown2rst
25 25
26 26
27 27 #-----------------------------------------------------------------------------
28 28 # Class
29 29 #-----------------------------------------------------------------------------
30 30
31 31 class TestMarkdown(TestsBase):
32 32
33 33 tests = [
34 34 '*test',
35 35 '**test',
36 36 '*test*',
37 37 '_test_',
38 38 '__test__',
39 39 '__*test*__',
40 40 '**test**',
41 41 '#test',
42 42 '##test',
43 43 'test\n----',
44 44 'test [link](https://google.com/)']
45 45
46 46 tokens = [
47 47 '*test',
48 48 '**test',
49 49 'test',
50 50 'test',
51 51 'test',
52 52 'test',
53 53 'test',
54 54 'test',
55 55 'test',
56 56 'test',
57 57 ('test', 'https://google.com/')]
58 58
59 59
60 60 @dec.onlyif_cmds_exist('pandoc')
61 @dec.parametric
62 61 def test_markdown2latex(self):
63 62 """markdown2latex test"""
64 63 for index, test in enumerate(self.tests):
65 yield self._try_markdown, markdown2latex, test, self.tokens[index]
64 yield self._try_markdown(markdown2latex, test, self.tokens[index])
66 65
67 66
68 67 @dec.onlyif_cmds_exist('pandoc')
69 @dec.parametric
70 68 def test_markdown2html(self):
71 69 """markdown2html test"""
72 70 for index, test in enumerate(self.tests):
73 yield self._try_markdown, markdown2html, test, self.tokens[index]
71 yield self._try_markdown(markdown2html, test, self.tokens[index])
74 72
75 73
76 74 @dec.onlyif_cmds_exist('pandoc')
77 @dec.parametric
78 75 def test_markdown2rst(self):
79 76 """markdown2rst test"""
80 77
81 78 #Modify token array for rst, escape asterik
82 79 tokens = copy(self.tokens)
83 80 tokens[0] = r'\*test'
84 81 tokens[1] = r'\*\*test'
85 82
86 83 for index, test in enumerate(self.tests):
87 yield self._try_markdown, markdown2rst, test, tokens[index]
84 yield self._try_markdown(markdown2rst, test, tokens[index])
88 85
89 86
90 87 def _try_markdown(self, method, test, tokens):
91 88 results = method(test)
92 89 if isinstance(tokens, string_types):
93 90 assert tokens in results
94 91 else:
95 92 for token in tokens:
96 93 assert token in results
@@ -1,122 +1,119 b''
1 1 """
2 2 Module with tests for Strings
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from IPython.testing import decorators as dec
18 18 from ...tests.base import TestsBase
19 19 from ..strings import (wrap_text, html2text, add_anchor, strip_dollars,
20 20 strip_files_prefix, get_lines, comment_lines, ipython2python)
21 21
22 22
23 23 #-----------------------------------------------------------------------------
24 24 # Class
25 25 #-----------------------------------------------------------------------------
26 26
27 27 class TestStrings(TestsBase):
28 28
29 @dec.parametric
30 29 def test_wrap_text(self):
31 30 """wrap_text test"""
32 31 test_text = """
33 32 Tush! never tell me; I take it much unkindly
34 33 That thou, Iago, who hast had my purse
35 34 As if the strings were thine, shouldst know of this.
36 35 """
37 36 for length in [30,5,1]:
38 yield self._confirm_wrap_text, test_text, length
37 yield self._confirm_wrap_text(test_text, length)
39 38
40 39
41 40 def _confirm_wrap_text(self, text, length):
42 41 for line in wrap_text(text, length).split('\n'):
43 42 assert len(line) <= length
44 43
45 44
46 45 def test_html2text(self):
47 46 """html2text test"""
48 47 #TODO: More tests
49 self.assert_equal(html2text('<name>joe</name>'), 'joe')
48 self.assertEqual(html2text('<name>joe</name>'), 'joe')
50 49
51 50
52 51 def test_add_anchor(self):
53 52 """add_anchor test"""
54 53 #TODO: More tests
55 54 results = add_anchor('<b>Hello World!</b>')
56 55 assert 'Hello World!' in results
57 56 assert 'id="' in results
58 57 assert 'class="anchor-link"' in results
59 58 assert '<b' in results
60 59 assert '</b>' in results
61 60
62 61
63 @dec.parametric
64 62 def test_strip_dollars(self):
65 63 """strip_dollars test"""
66 64 tests = [
67 65 ('', ''),
68 66 ('$$', ''),
69 67 ('$H$', 'H'),
70 68 ('$He', 'He'),
71 69 ('H$el', 'H$el'),
72 70 ('Hell$', 'Hell'),
73 71 ('Hello', 'Hello'),
74 72 ('W$o$rld', 'W$o$rld')]
75 73 for test in tests:
76 yield self._try_strip_dollars, test[0], test[1]
74 yield self._try_strip_dollars(test[0], test[1])
77 75
78 76
79 77 def _try_strip_dollars(self, test, result):
80 self.assert_equal(strip_dollars(test), result)
78 self.assertEqual(strip_dollars(test), result)
81 79
82 80
83 @dec.parametric
84 81 def test_strip_files_prefix(self):
85 82 """strip_files_prefix test"""
86 83 tests = [
87 84 ('', ''),
88 85 ('/files', '/files'),
89 86 ('test="/files"', 'test="/files"'),
90 87 ('My files are in `files/`', 'My files are in `files/`'),
91 88 ('<a href="files/test.html">files/test.html</a>', '<a href="test.html">files/test.html</a>')]
92 89 for test in tests:
93 yield self._try_files_prefix, test[0], test[1]
90 yield self._try_files_prefix(test[0], test[1])
94 91
95 92
96 93 def _try_files_prefix(self, test, result):
97 self.assert_equal(strip_files_prefix(test), result)
94 self.assertEqual(strip_files_prefix(test), result)
98 95
99 96
100 97 def test_comment_lines(self):
101 98 """comment_lines test"""
102 99 for line in comment_lines('hello\nworld\n!').split('\n'):
103 100 assert line.startswith('# ')
104 101 for line in comment_lines('hello\nworld\n!', 'beep').split('\n'):
105 102 assert line.startswith('beep')
106 103
107 104
108 105 def test_get_lines(self):
109 106 """get_lines test"""
110 107 text = "hello\nworld\n!"
111 self.assert_equal(get_lines(text, start=1), "world\n!")
112 self.assert_equal(get_lines(text, end=2), "hello\nworld")
113 self.assert_equal(get_lines(text, start=2, end=5), "!")
114 self.assert_equal(get_lines(text, start=-2), "world\n!")
108 self.assertEqual(get_lines(text, start=1), "world\n!")
109 self.assertEqual(get_lines(text, end=2), "hello\nworld")
110 self.assertEqual(get_lines(text, start=2, end=5), "!")
111 self.assertEqual(get_lines(text, start=-2), "world\n!")
115 112
116 113
117 114 def test_ipython2python(self):
118 115 """ipython2python test"""
119 116 #TODO: More tests
120 117 results = ipython2python(u'%%pylab\nprint("Hello-World")').replace("u'", "'")
121 118 self.fuzzy_compare(results, u"get_ipython().run_cell_magic('pylab', '', 'print(\"Hello-World\")')",
122 119 ignore_spaces=True, ignore_newlines=True)
@@ -1,151 +1,143 b''
1 1 """
2 2 Contains base test class for nbconvert
3 3 """
4 4 #-----------------------------------------------------------------------------
5 5 #Copyright (c) 2013, the IPython Development Team.
6 6 #
7 7 #Distributed under the terms of the Modified BSD License.
8 8 #
9 9 #The full license is in the file COPYING.txt, distributed with this software.
10 10 #-----------------------------------------------------------------------------
11 11
12 12 #-----------------------------------------------------------------------------
13 13 # Imports
14 14 #-----------------------------------------------------------------------------
15 15
16 16 import os
17 17 import glob
18 18 import shutil
19 19
20 from nose.tools import assert_equal
21 20 import IPython
22 21 from IPython.utils.tempdir import TemporaryWorkingDirectory
23 22 from IPython.utils.process import get_output_error_code
24 23 from IPython.testing.tools import get_ipython_cmd
24 from IPython.testing.ipunittest import ParametricTestCase
25 25
26 26 # a trailing space allows for simpler concatenation with the other arguments
27 27 ipy_cmd = get_ipython_cmd(as_string=True) + " "
28 28
29 29 #-----------------------------------------------------------------------------
30 30 # Classes and functions
31 31 #-----------------------------------------------------------------------------
32 32
33 33
34 class TestsBase(object):
34 class TestsBase(ParametricTestCase):
35 35 """Base tests class. Contains useful fuzzy comparison and nbconvert
36 36 functions."""
37 37
38 38
39 def __init__(self):
40
41 # We need to manually add assert_equal to the class instead of inheriting
42 # from unittest.TestCase because if we inherit from unittest.TestCase
43 # support for test generators is lost (a known 'feature' of nose).
44 self.assert_equal = assert_equal
45
46
47 39 def fuzzy_compare(self, a, b, newlines_are_spaces=True, tabs_are_spaces=True,
48 40 fuzzy_spacing=True, ignore_spaces=False,
49 41 ignore_newlines=False, case_sensitive=False, leave_padding=False):
50 42 """
51 43 Performs a fuzzy comparison of two strings. A fuzzy comparison is a
52 44 comparison that ignores insignificant differences in the two comparands.
53 45 The significance of certain differences can be specified via the keyword
54 46 parameters of this method.
55 47 """
56 48
57 49 if not leave_padding:
58 50 a = a.strip()
59 51 b = b.strip()
60 52
61 53 if ignore_newlines:
62 54 a = a.replace('\n', '')
63 55 b = b.replace('\n', '')
64 56
65 57 if newlines_are_spaces:
66 58 a = a.replace('\n', ' ')
67 59 b = b.replace('\n', ' ')
68 60
69 61 if tabs_are_spaces:
70 62 a = a.replace('\t', ' ')
71 63 b = b.replace('\t', ' ')
72 64
73 65 if ignore_spaces:
74 66 a = a.replace(' ', '')
75 67 b = b.replace(' ', '')
76 68
77 69 if fuzzy_spacing:
78 70 a = self.recursive_replace(a, ' ', ' ')
79 71 b = self.recursive_replace(b, ' ', ' ')
80 72
81 73 if not case_sensitive:
82 74 a = a.lower()
83 75 b = b.lower()
84 76
85 self.assert_equal(a, b)
77 self.assertEqual(a, b)
86 78
87 79
88 80 def recursive_replace(self, text, search, replacement):
89 81 """
90 82 Performs a recursive replacement operation. Replaces all instances
91 83 of a search string in a text string with a replacement string until
92 84 the search string no longer exists. Recursion is needed because the
93 85 replacement string may generate additional search strings.
94 86
95 87 For example:
96 88 Replace "ii" with "i" in the string "Hiiii" yields "Hii"
97 89 Another replacement yields "Hi" (the desired output)
98 90
99 91 Parameters:
100 92 -----------
101 93 text : string
102 94 Text to replace in.
103 95 search : string
104 96 String to search for within "text"
105 97 replacement : string
106 98 String to replace "search" with
107 99 """
108 100 while search in text:
109 101 text = text.replace(search, replacement)
110 102 return text
111 103
112 104 def create_temp_cwd(self, copy_filenames=None):
113 105 temp_dir = TemporaryWorkingDirectory()
114 106
115 107 #Copy the files if requested.
116 108 if copy_filenames is not None:
117 109 self.copy_files_to(copy_filenames)
118 110
119 111 #Return directory handler
120 112 return temp_dir
121 113
122 114
123 115 def copy_files_to(self, copy_filenames, dest='.'):
124 116 "Copy test files into the destination directory"
125 117 if not os.path.isdir(dest):
126 118 os.makedirs(dest)
127 119 files_path = self._get_files_path()
128 120 for pattern in copy_filenames:
129 121 for match in glob.glob(os.path.join(files_path, pattern)):
130 122 shutil.copyfile(match, os.path.join(dest, os.path.basename(match)))
131 123
132 124
133 125 def _get_files_path(self):
134 126
135 127 #Get the relative path to this module in the IPython directory.
136 128 names = self.__module__.split('.')[1:-1]
137 129 names.append('files')
138 130
139 131 #Build a path using the IPython directory and the relative path we just
140 132 #found.
141 133 path = IPython.__path__[0]
142 134 for name in names:
143 135 path = os.path.join(path, name)
144 136 return path
145 137
146 138
147 139 def call(self, parameters, raise_on_error=True):
148 140 stdout, stderr, retcode = get_output_error_code(ipy_cmd + parameters)
149 141 if retcode != 0 and raise_on_error:
150 142 raise OSError(stderr)
151 143 return stdout, stderr
General Comments 0
You need to be logged in to leave comments. Login now