##// END OF EJS Templates
fix symlinked /home issue for FreeBSD...
fix symlinked /home issue for FreeBSD this is a one-line fix for ipython's pushd and friends on systems which symlink /home directories to /usr/home. Here's the error I get on FreeBSD 9.0 without this PR: ====================================================================== FAIL: Test various directory handling operations. ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest self.test(*self.arg) File "/usr/home/pi/code/ipython/IPython/core/tests/test_magic.py", line 280, in test_dirops nt.assert_equal(curpath(), startdir) AssertionError: u'/usr/home/pi/.ipython' != u'/usr/home/pi/code/ipython' - /usr/home/pi/.ipython ? ^ + /usr/home/pi/code/ipython ? ^^^^^ """Fail immediately, with the given message.""" >> raise self.failureException(u"u'/usr/home/pi/.ipython' != u'/usr/home/pi/code/ipython'\n- /usr/home/pi/.ipython\n? ^\n+ /usr/home/pi/code/ipython\n? ^^^^^\n") -------------------- >> begin captured stdout << --------------------- /usr/home/pi/.ipython /usr/home/pi/code/ipython /usr/home/pi/.ipython [Errno 2] No such file or directory: '/usr~/code/ipython' /usr/home/pi/.ipython popd -> /usr~/code/ipython --------------------- >> end captured stdout << ---------------------- The reason for the above is this: In [1]: pwd Out[1]: u'/usr/home/pi' In [2]: !pwd /home/pi In [3]: pushd code /usr/home/pi/code Out[3]: [u'/usr~'] with this commit: In [1]: pushd Out[1]: [u'~']

File last commit:

r5529:a1b74bc4
r6112:542170a5
Show More
nosepatch.py
76 lines | 2.8 KiB | text/x-python | PythonLexer
"""Monkeypatch nose to accept any callable as a method.
By default, nose's ismethod() fails for static methods.
Once this is fixed in upstream nose we can disable it.
Notes:
- As of Nose 1.0.0, the problem persists so this monkeypatch is still
needed.
- Merely importing this module causes the monkeypatch to be applied."""
#-----------------------------------------------------------------------------
# Copyright (C) 2009-2011 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
import sys
import nose.loader
from inspect import ismethod, isfunction
#-----------------------------------------------------------------------------
# Classes and functions
#-----------------------------------------------------------------------------
def getTestCaseNames(self, testCaseClass):
"""Override to select with selector, unless
config.getTestCaseNamesCompat is True
"""
if self.config.getTestCaseNamesCompat:
return unittest.TestLoader.getTestCaseNames(self, testCaseClass)
def wanted(attr, cls=testCaseClass, sel=self.selector):
item = getattr(cls, attr, None)
# MONKEYPATCH: replace this:
#if not ismethod(item):
# return False
# return sel.wantMethod(item)
# With:
if ismethod(item):
return sel.wantMethod(item)
# static method or something. If this is a static method, we
# can't get the class information, and we have to treat it
# as a function. Thus, we will miss things like class
# attributes for test selection
if isfunction(item):
return sel.wantFunction(item)
return False
# END MONKEYPATCH
cases = filter(wanted, dir(testCaseClass))
for base in testCaseClass.__bases__:
for case in self.getTestCaseNames(base):
if case not in cases:
cases.append(case)
# add runTest if nothing else picked
if not cases and hasattr(testCaseClass, 'runTest'):
cases = ['runTest']
if self.sortTestMethodsUsing:
cases.sort(self.sortTestMethodsUsing)
return cases
##########################################################################
# Apply monkeypatch here
# Python 3 must be running with newer version of Nose, so don't touch anything.
if sys.version_info[0] < 3:
nose.loader.TestLoader.getTestCaseNames = getTestCaseNames
##########################################################################