##// END OF EJS Templates
Merge pull request #4504 from takluyver/inputtransformer-syntaxerror...
Merge pull request #4504 from takluyver/inputtransformer-syntaxerror Allow input transformers to raise SyntaxError, if they consider a line of input code invalid. The main motivating use case for this was Sage, this is a continuation of @vbraun's gh-4089. For background, see http://python.6.x6.nabble.com/Raising-a-SyntaxError-in-InputTransformer-td5027773.html. Also, took advantage of the opportunity to refactor and simplify `run_cell` a bit.

File last commit:

r12781:1411cb6d
r14990:07072a49 merge
Show More
base.py
42 lines | 1.3 KiB | text/x-python | PythonLexer
"""
Contains base test class for nbformat
"""
#-----------------------------------------------------------------------------
#Copyright (c) 2013, the IPython Development Team.
#
#Distributed under the terms of the Modified BSD License.
#
#The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import os
import unittest
import IPython
#-----------------------------------------------------------------------------
# Classes and functions
#-----------------------------------------------------------------------------
class TestsBase(unittest.TestCase):
"""Base tests class."""
def fopen(self, f, mode=u'r'):
return open(os.path.join(self._get_files_path(), f), mode)
def _get_files_path(self):
#Get the relative path to this module in the IPython directory.
names = self.__module__.split(u'.')[1:-1]
#Build a path using the IPython directory and the relative path we just
#found.
path = IPython.__path__[0]
for name in names:
path = os.path.join(path, name)
return path