timbertson / autonose

autotest-like runner for nosetests
57 stars 8 forks source link

autonose dies when using custom exception class #21

Closed winstonewert closed 13 years ago

winstonewert commented 13 years ago

My code in test_fail.py

class SomeError(Exception):
    pass

def foo():
    raise SomeError()

def test_foo():
    foo()

When I invoke autonose --debug:

[DEBUG] autonose.scanner: IOError:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/autonose-0.2.1-py2.7.egg/autonose/scanner.py", line 27, in load
    picklefile = open_file(path)
  File "/usr/local/lib/python2.7/dist-packages/autonose-0.2.1-py2.7.egg/autonose/scanner.py", line 16, in open_file
    return open(path, *a)
IOError: [Errno 2] No such file or directory: '/home/winston/Dropbox/SE/transforms/alone/.autonose-depends.pickle'
[INFO] autonose.shared.state.summary: added: test_fail.py
[DEBUG] autonose.shared.file_state: fetching dependencies for test_fail.py
[DEBUG] root:     Line 1: Symbol is not a module: 'nose.tools.assert_equals'
[DEBUG] root:     Line 1: Symbol is not a module: 'nose.tools.assert_raises'
[DEBUG] autonose.shared.file_state: ("    Line %d: Symbol is not a module: '%s'", 'nose.tools.assert_equals')
[DEBUG] autonose.shared.file_state: ("    Line %d: Symbol is not a module: '%s'", 'nose.tools.assert_raises')
[DEBUG] autonose.shared.file_state: found dependant files: ['/usr/share/pyshared/nose/tools.py', '/usr/share/pyshared/nose/tools.py']
[DEBUG] autonose.shared.file_state: rel_paths: []
[DEBUG] autonose.shared.state: ALTERING path: test_fail.py
[DEBUG] autonose.shared.state: ignoring non-python file: test_fail.pyc
[INFO] autonose.shared.state.summary: all affected files:    
  test_fail.py
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/autonose-0.2.1-py2.7.egg/autonose/runner.py", line 163, in init_ui
    App = default_app()
  File "/usr/local/lib/python2.7/dist-packages/autonose-0.2.1-py2.7.egg/autonose/ui/platform.py", line 7, in default_app
    from gtkapp import App
  File "/usr/local/lib/python2.7/dist-packages/autonose-0.2.1-py2.7.egg/autonose/ui/gtkapp.py", line 15, in <module>
    from shared import urlparse
  File "/usr/local/lib/python2.7/dist-packages/autonose-0.2.1-py2.7.egg/autonose/ui/shared/__init__.py", line 1, in <module>
    from main import Main
  File "/usr/local/lib/python2.7/dist-packages/autonose-0.2.1-py2.7.egg/autonose/ui/shared/main.py", line 2, in <module>
    from shared.test_result import ResultEvent
ImportError: No module named shared.test_result
UI load failed - falling back to basic console
----------------------------------------
[INFO] runner: running with 1 affected and 1 bad files... (1 files total)
[DEBUG] runner: state is: 
<FileState: test_fail.py@1317915600.33, test_results:<TestResults [ok]: []> (depends on 0 files)>
[DEBUG] runner: args are: ['nosetests', '--exe']

# Running tests at 10:43:03  

[DEBUG] nose.plugins.manager: DefaultPluginManager load plugin EARLPlugin = rdflib_tools.EARLPlugin:EARLPlugin
[INFO] rdflib: version: 2.4.2
Traceback (most recent call last):
E
======================================================================
ERROR: test_fail.test_foo
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/nose/case.py", line 186, in runTest
    self.test(*self.arg)
  File "/home/winston/Dropbox/SE/transforms/alone/test_fail.py", line 10, in test_foo
    foo()
  File "/home/winston/Dropbox/SE/transforms/alone/test_fail.py", line 7, in foo
    raise SomeError()
SomeError
Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/paragram/process/base_process.py", line 212, in _run
----------------------------------------------------------------------
Ran 1 test in 0.004s

FAILED (errors=1)
    self._receive(pickle.loads(pickled))
  File "/usr/lib/python2.7/pickle.py", line 1382, in loads
  File "/usr/local/lib/python2.7/dist-packages/paragram/process/base_process.py", line 212, in _run
    self._receive(pickle.loads(pickled))
  File "/usr/lib/python2.7/pickle.py", line 1382, in loads
    return Unpickler(file).load()
  File "/usr/lib/python2.7/pickle.py", line 858, in load
    dispatch[key](self)
  File "/usr/lib/python2.7/pickle.py", line 1090, in load_global
    klass = self.find_class(module, name)
  File "/usr/lib/python2.7/pickle.py", line 1124, in find_class
    __import__(module)
ImportError: No module named test_fail
    return Unpickler(file).load()
  File "/usr/lib/python2.7/pickle.py", line 858, in load
    dispatch[key](self)
  File "/usr/lib/python2.7/pickle.py", line 1090, in load_global
    klass = self.find_class(module, name)
  File "/usr/lib/python2.7/pickle.py", line 1124, in find_class
    __import__(module)
ImportError: No module named test_fail
Exception in thread monitor-state-changes:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/paragram/process/base_process.py", line 217, in _run
    self._exit(e.error)
  File "/usr/local/lib/python2.7/dist-packages/paragram/process/base_process.py", line 235, in _exit
    self._finished.set()
  File "/usr/lib/python2.7/multiprocessing/managers.py", line 1010, in set
    return self._callmethod('set')
  File "/usr/lib/python2.7/multiprocessing/managers.py", line 773, in _callmethod
    raise convert_to_error(kind, result)
RemoteError: 
---------------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/managers.py", line 242, in serve_client
    obj, exposed, gettypeid = id_to_obj[ident]
KeyError: '8ecadec'
---------------------------------------------------------------------------

Stats: Python 2.7 Ubuntu 11.04 copy of autonose cloned from github

It looks like something is trying to unpickle the exception object from inside test_fail.py. However, it cannot import it probably because its not on sys.path, but rather in the local directory.

timbertson commented 13 years ago

Thanks for the report. autonose already avoids pickling the exception instance itself, but still pickles the type. That's unnecessary (we only need the name of the type), so it's fixed in f627933a915fb35f6e718e32673a26b7d786ae2c