##// END OF EJS Templates
Skip some failing tests on Windows...
Thomas Kluyver -
Show More
@@ -1,64 +1,68 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Tests for shellapp module.
3 3
4 4 Authors
5 5 -------
6 6 * Bradley Froehle
7 7 """
8 8 #-----------------------------------------------------------------------------
9 9 # Copyright (C) 2012 The IPython Development Team
10 10 #
11 11 # Distributed under the terms of the BSD License. The full license is in
12 12 # the file COPYING, distributed as part of this software.
13 13 #-----------------------------------------------------------------------------
14 14
15 15 #-----------------------------------------------------------------------------
16 16 # Imports
17 17 #-----------------------------------------------------------------------------
18 18 import unittest
19 19
20 20 from IPython.testing import decorators as dec
21 21 from IPython.testing import tools as tt
22 22 from IPython.utils.py3compat import PY3
23 23
24 24 sqlite_err_maybe = dec.module_not_available('sqlite3')
25 25 SQLITE_NOT_AVAILABLE_ERROR = ('WARNING: IPython History requires SQLite,'
26 26 ' your history will not be saved\n')
27 27
28 28 class TestFileToRun(unittest.TestCase, tt.TempFileMixin):
29 29 """Test the behavior of the file_to_run parameter."""
30 30
31 31 def test_py_script_file_attribute(self):
32 32 """Test that `__file__` is set when running `ipython file.py`"""
33 33 src = "print(__file__)\n"
34 34 self.mktmp(src)
35 35
36 36 err = SQLITE_NOT_AVAILABLE_ERROR if sqlite_err_maybe else None
37 37 tt.ipexec_validate(self.fname, self.fname, err)
38 38
39 39 def test_ipy_script_file_attribute(self):
40 40 """Test that `__file__` is set when running `ipython file.ipy`"""
41 41 src = "print(__file__)\n"
42 42 self.mktmp(src, ext='.ipy')
43 43
44 44 err = SQLITE_NOT_AVAILABLE_ERROR if sqlite_err_maybe else None
45 45 tt.ipexec_validate(self.fname, self.fname, err)
46 46
47 # The commands option to ipexec_validate doesn't work on Windows, and it
48 # doesn't seem worth fixing
49 @dec.skip_win32
47 50 def test_py_script_file_attribute_interactively(self):
48 51 """Test that `__file__` is not set after `ipython -i file.py`"""
49 52 src = "True\n"
50 53 self.mktmp(src)
51 54
52 55 err = SQLITE_NOT_AVAILABLE_ERROR if sqlite_err_maybe else None
53 56 tt.ipexec_validate(self.fname, 'False', err, options=['-i'],
54 57 commands=['"__file__" in globals()', 'exit()'])
55 58
59 @dec.skip_win32
56 60 @dec.skipif(PY3)
57 61 def test_py_script_file_compiler_directive(self):
58 62 """Test `__future__` compiler directives with `ipython -i file.py`"""
59 63 src = "from __future__ import division\n"
60 64 self.mktmp(src)
61 65
62 66 err = SQLITE_NOT_AVAILABLE_ERROR if sqlite_err_maybe else None
63 67 tt.ipexec_validate(self.fname, 'float', err, options=['-i'],
64 68 commands=['type(1/2)', 'exit()'])
General Comments 0
You need to be logged in to leave comments. Login now