##// END OF EJS Templates
Fix warning when running IPython.kernel tests...
Fix warning when running IPython.kernel tests The signature of TemporaryDirectory.cleanup() changed just before Python 3.2, and our TemporaryWorkingDirectory subclass was receiving an unexpected parameter. This copies in a newer TemporaryDirectory.cleanup() implementation for Python 2.7.

File last commit:

r11124:9567c77a
r12165:def58361
Show More
test_shellapp.py
49 lines | 1.8 KiB | text/x-python | PythonLexer
# -*- coding: utf-8 -*-
"""Tests for shellapp module.
Authors
-------
* Bradley Froehle
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2012 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import unittest
from IPython.testing import decorators as dec
from IPython.testing import tools as tt
class TestFileToRun(unittest.TestCase, tt.TempFileMixin):
"""Test the behavior of the file_to_run parameter."""
def test_py_script_file_attribute(self):
"""Test that `__file__` is set when running `ipython file.py`"""
src = "print(__file__)\n"
self.mktmp(src)
if dec.module_not_available('sqlite3'):
err = 'WARNING: IPython History requires SQLite, your history will not be saved\n'
else:
err = None
tt.ipexec_validate(self.fname, self.fname, err)
def test_ipy_script_file_attribute(self):
"""Test that `__file__` is set when running `ipython file.ipy`"""
src = "print(__file__)\n"
self.mktmp(src, ext='.ipy')
if dec.module_not_available('sqlite3'):
err = 'WARNING: IPython History requires SQLite, your history will not be saved\n'
else:
err = None
tt.ipexec_validate(self.fname, self.fname, err)
# Ideally we would also test that `__file__` is not set in the
# interactive namespace after running `ipython -i <file>`.