##// END OF EJS Templates
Backport PR #9883: resolve path to temporary directory to ensure that 'assert_equal' tests also work when $TMPDIR is a symlink...
Backport PR #9883: resolve path to temporary directory to ensure that 'assert_equal' tests also work when $TMPDIR is a symlink If `$TMPDIR` is a symlink (e.g. `TMPDIR=/local` with `/local` -> `/tmp`), one of the tests fails with the error below due to a hard string comparison of paths using `assert_equals` (see below) this patch fixes the problem by resolving the path returned by `tempfile.mkdtemp()` ``` ====================================================================== FAIL: IPython.core.tests.test_paths.test_get_ipython_cache_dir ---------------------------------------------------------------------- Traceback (most recent call last): File "/user/home/gent/vsc400/vsc40023/eb_phanpyscratch/SL6/sandybridge/software/IPython/5.0.0-foss-2016a-Python-2.7.11/lib/python2.7/site-packages/nose-1.3.7-py2.7.egg/nose/case.py", line 197, in runTest self.test(*self.arg) File "/user/home/gent/vsc400/vsc40023/eb_phanpyscratch/SL6/sandybridge/software/IPython/5.0.0-foss-2016a-Python-2.7.11/lib/python2.7/site-packages/IPython/core/tests/test_paths.py", line 185, in test_get_ipython_cache_dir ipdir) AssertionError: '/local/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython' != u'/tmp/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython' "'/local/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython' != u'/tmp/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython'" = '%s != %s' % (safe_repr('/local/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython'), safe_repr(u'/tmp/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython')) "'/local/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython' != u'/tmp/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython'" = self._formatMessage("'/local/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython' != u'/tmp/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython'", "'/local/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython' != u'/tmp/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython'") >> raise self.failureException("'/local/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython' != u'/tmp/2541261X3368X.master15.delcatty.gent.vsc/eb-b7oBry/tmpoxweQW/tmpZurEih/home_test_dir/.cache/ipython'") ---------------------------------------------------------------------- Ran 520 tests in 34.490s FAILED (SKIP=11, failures=1) ```

File last commit:

r21874:3ffdf6f9
r22888:39d8b89f
Show More
magics.py
45 lines | 1.4 KiB | text/x-python | PythonLexer
import re
from sphinx import addnodes
from sphinx.domains.std import StandardDomain
from sphinx.roles import XRefRole
name_re = re.compile(r"[\w_]+")
def parse_magic(env, sig, signode):
m = name_re.match(sig)
if not m:
raise Exception("Invalid magic command: %s" % sig)
name = "%" + sig
signode += addnodes.desc_name(name, name)
return m.group(0)
class LineMagicRole(XRefRole):
"""Cross reference role displayed with a % prefix"""
prefix = "%"
def process_link(self, env, refnode, has_explicit_title, title, target):
if not has_explicit_title:
title = self.prefix + title.lstrip("%")
target = target.lstrip("%")
return title, target
def parse_cell_magic(env, sig, signode):
m = name_re.match(sig)
if not m:
raise ValueError("Invalid cell magic: %s" % sig)
name = "%%" + sig
signode += addnodes.desc_name(name, name)
return m.group(0)
class CellMagicRole(LineMagicRole):
"""Cross reference role displayed with a %% prefix"""
prefix = "%%"
def setup(app):
app.add_object_type('magic', 'magic', 'pair: %s; magic command', parse_magic)
StandardDomain.roles['magic'] = LineMagicRole()
app.add_object_type('cellmagic', 'cellmagic', 'pair: %s; cell magic', parse_cell_magic)
StandardDomain.roles['cellmagic'] = CellMagicRole()
metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
return metadata