11# encoding: utf-8
22"""Tests for IPython.utils.path.py"""
33
4- #-----------------------------------------------------------------------------
5- # Copyright (C) 2008-2011 The IPython Development Team
6- #
7- # Distributed under the terms of the BSD License. The full license is in
8- # the file COPYING, distributed as part of this software.
9- #-----------------------------------------------------------------------------
4+ # Copyright (c) IPython Development Team.
5+ # Distributed under the terms of the Modified BSD License.
6+
7+ try :
8+ from unittest .mock import patch
9+ except ImportError :
10+ from mock import patch
1011
1112import nose .tools as nt
1213
1314from IPython .lib import latextools
1415from IPython .testing .decorators import onlyif_cmds_exist , skipif_not_matplotlib
15- from IPython .testing .tools import monkeypatch
1616from IPython .utils .process import FindCmdError
1717
1818
@@ -29,7 +29,7 @@ def mock_find_cmd(arg):
2929 if arg == command :
3030 raise FindCmdError
3131
32- with monkeypatch (latextools , "find_cmd" , mock_find_cmd ):
32+ with patch . object (latextools , "find_cmd" , mock_find_cmd ):
3333 nt .assert_equals (latextools .latex_to_png_dvipng ("whatever" , True ),
3434 None )
3535
@@ -46,7 +46,7 @@ def mock_kpsewhich(filename):
4646 for (s , wrap ) in [(u"$$x^2$$" , False ), (u"x^2" , True )]:
4747 yield (latextools .latex_to_png_dvipng , s , wrap )
4848
49- with monkeypatch (latextools , "kpsewhich" , mock_kpsewhich ):
49+ with patch . object (latextools , "kpsewhich" , mock_kpsewhich ):
5050 yield (latextools .latex_to_png_dvipng , s , wrap )
5151
5252@skipif_not_matplotlib
@@ -61,7 +61,7 @@ def mock_kpsewhich(filename):
6161 for (s , wrap ) in [("$x^2$" , False ), ("x^2" , True )]:
6262 yield (latextools .latex_to_png_mpl , s , wrap )
6363
64- with monkeypatch (latextools , "kpsewhich" , mock_kpsewhich ):
64+ with patch . object (latextools , "kpsewhich" , mock_kpsewhich ):
6565 yield (latextools .latex_to_png_mpl , s , wrap )
6666
6767@skipif_not_matplotlib
@@ -78,7 +78,7 @@ def mock_kpsewhich(filename):
7878 assert False , ("kpsewhich should not be called "
7979 "(called with {0})" .format (filename ))
8080
81- with monkeypatch (latextools , "kpsewhich" , mock_kpsewhich ):
81+ with patch . object (latextools , "kpsewhich" , mock_kpsewhich ):
8282 nt .assert_equals (
8383 '\n ' .join (latextools .genelatex ("body text" , False )),
8484 r'''\documentclass{article}
@@ -100,7 +100,7 @@ def mock_kpsewhich(filename):
100100 nt .assert_equals (filename , "breqn.sty" )
101101 return "path/to/breqn.sty"
102102
103- with monkeypatch (latextools , "kpsewhich" , mock_kpsewhich ):
103+ with patch . object (latextools , "kpsewhich" , mock_kpsewhich ):
104104 nt .assert_equals (
105105 '\n ' .join (latextools .genelatex ("x^2" , True )),
106106 r'''\documentclass{article}
@@ -125,7 +125,7 @@ def mock_kpsewhich(filename):
125125 nt .assert_equals (filename , "breqn.sty" )
126126 return None
127127
128- with monkeypatch (latextools , "kpsewhich" , mock_kpsewhich ):
128+ with patch . object (latextools , "kpsewhich" , mock_kpsewhich ):
129129 nt .assert_equals (
130130 '\n ' .join (latextools .genelatex ("x^2" , True )),
131131 r'''\documentclass{article}
0 commit comments