sk- / elcap

Nose plugin that test mutated versions of your source code
12 stars 1 forks source link

Usage #2

Open doctorlove opened 8 years ago

doctorlove commented 8 years ago

The README says Usage: $ nosetests --with-mutations But I get nosetests: error: no such option: --with-mutations I have nosetests: error: no such option: --with-mutations

doctorlove commented 8 years ago

It also needed unittest2.

If I run your tests I get this output:

C:\Python27\lib\site-packages\nose\plugins\manager.py:395: RuntimeWarning: Unable to load plugin mutations = elcap.plugins:Mutations: No module named elcap.plugins RuntimeWarning)

............Running original tests

Testing mutated files


0 mutations performed (survived 0) on 0 files in 0.000s

.....E...E....

ERROR: Failure: ImportError (No module named samplemutator)

Traceback (most recent call last): File "C:\Python27\lib\site-packages\nose\loader.py", line 418, in loadTestsFromName addr.filename, addr.module) File "C:\Python27\lib\site-packages\nose\importer.py", line 47, in importFromPath return self.importFromDir(dir_path, fqname) File "C:\Python27\lib\site-packages\nose\importer.py", line 94, in importFromDir mod = load_module(part_fqname, fh, filename, desc) File "C:\dev\elcap\tests\test_mutator.py", line 7, in import testpackage.samplemutator as samplemutator ImportError: No module named samplemutator

ERROR: test_coverage (test_plugins.TestTestCoveragePlugin)

Traceback (most recent call last): File "C:\dev\elcap\tests\test_plugins.py", line 28, in test_coverage plugin.afterTest(testa) File "C:\dev\elcap\elcap\coverage_plugin.py", line 45, in afterTest self.cover_instance.stop() TypeError: 'instancemethod' object has no attribute 'getitem' -------------------- >> begin captured stdout << --------------------- f g

--------------------- >> end captured stdout << ----------------------


Ran 26 tests in 0.406s

FAILED (errors=2) C:\Python27\lib\multiprocessing\connection.py:426: RuntimeWarning: Parent module 'multiprocessing' not found while handling absolute import import hmac

sk- commented 8 years ago

Hi Frances, thanks for reporting the issue.

This project is no longer maintained and I wrote a few years ago, and I guess now the nose API has changed a little bit.

I tried running the test and got a different errors than yours.

...........EEE..../usr/local/lib/python2.7/dist-packages/nose/result.py:182: RuntimeWarning: Parent module 'nose' not found while handling absolute import
  from nose.plugins.skip import SkipTest
Traceback (most recent call last):
  File "/usr/local/bin/nosetests", line 9, in <module>
    load_entry_point('nose==1.3.7', 'console_scripts', 'nosetests')()
  File "/usr/local/lib/python2.7/dist-packages/nose/core.py", line 121, in __init__
    **extra_args)
  File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
    self.runTests()
  File "/usr/local/lib/python2.7/dist-packages/nose/core.py", line 207, in runTests
    result = self.testRunner.run(self.test)
  File "/usr/local/lib/python2.7/dist-packages/nose/core.py", line 62, in run
    test(result)
  File "/usr/local/lib/python2.7/dist-packages/nose/suite.py", line 177, in __call__
    return self.run(*arg, **kw)
  File "/usr/local/lib/python2.7/dist-packages/nose/suite.py", line 224, in run
    test(orig)
  File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
    return self.run(*args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/nose/suite.py", line 75, in run
    test(result)
  File "/usr/local/lib/python2.7/dist-packages/nose/suite.py", line 177, in __call__
    return self.run(*arg, **kw)
  File "/usr/local/lib/python2.7/dist-packages/nose/suite.py", line 214, in run
    result.addError(self, self._exc_info())
  File "/usr/local/lib/python2.7/dist-packages/nose/proxy.py", line 132, in addError
    self.result.addError(self.test, self._prepareErr(err))
  File "/usr/local/lib/python2.7/dist-packages/nose/result.py", line 61, in addError
    exc_info = self._exc_info_to_string(err, test)
  File "/usr/local/lib/python2.7/dist-packages/nose/result.py", line 182, in _exc_info_to_string
    from nose.plugins.skip import SkipTest
  File "/usr/local/lib/python2.7/dist-packages/nose/__init__.py", line 1, in <module>
    from nose.core import collector, main, run, run_exit, runmodule
  File "/usr/local/lib/python2.7/dist-packages/nose/core.py", line 5, in <module>
    import logging
  File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
    import sys, os, time, cStringIO, traceback, warnings, weakref
  File "/usr/lib/python2.7/os.py", line 119, in <module>
    sys.modules['os.path'] = path
AttributeError: 'module' object has no attribute 'modules'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 66, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python2.7/dist-packages/apport/__init__.py", line 1, in <module>
    from apport.report import Report
  File "/usr/lib/python2.7/dist-packages/apport/report.py", line 12, in <module>
    import subprocess, tempfile, os.path, urllib, re, pwd, grp, os
  File "/usr/lib/python2.7/subprocess.py", line 394, in <module>
    import os
  File "/usr/lib/python2.7/os.py", line 119, in <module>
    sys.modules['os.path'] = path
AttributeError: 'module' object has no attribute 'modules'

Original exception was:
Traceback (most recent call last):
  File "/usr/local/bin/nosetests", line 9, in <module>
    load_entry_point('nose==1.3.7', 'console_scripts', 'nosetests')()
  File "/usr/local/lib/python2.7/dist-packages/nose/core.py", line 121, in __init__
    **extra_args)
  File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
    self.runTests()
  File "/usr/local/lib/python2.7/dist-packages/nose/core.py", line 207, in runTests
    result = self.testRunner.run(self.test)
  File "/usr/local/lib/python2.7/dist-packages/nose/core.py", line 62, in run
    test(result)
  File "/usr/local/lib/python2.7/dist-packages/nose/suite.py", line 177, in __call__
    return self.run(*arg, **kw)
  File "/usr/local/lib/python2.7/dist-packages/nose/suite.py", line 224, in run
    test(orig)
  File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
    return self.run(*args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/nose/suite.py", line 75, in run
    test(result)
  File "/usr/local/lib/python2.7/dist-packages/nose/suite.py", line 177, in __call__
    return self.run(*arg, **kw)
  File "/usr/local/lib/python2.7/dist-packages/nose/suite.py", line 214, in run
    result.addError(self, self._exc_info())
  File "/usr/local/lib/python2.7/dist-packages/nose/proxy.py", line 132, in addError
    self.result.addError(self.test, self._prepareErr(err))
  File "/usr/local/lib/python2.7/dist-packages/nose/result.py", line 61, in addError
    exc_info = self._exc_info_to_string(err, test)
  File "/usr/local/lib/python2.7/dist-packages/nose/result.py", line 182, in _exc_info_to_string
    from nose.plugins.skip import SkipTest
  File "/usr/local/lib/python2.7/dist-packages/nose/__init__.py", line 1, in <module>
    from nose.core import collector, main, run, run_exit, runmodule
  File "/usr/local/lib/python2.7/dist-packages/nose/core.py", line 5, in <module>
    import logging
  File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
    import sys, os, time, cStringIO, traceback, warnings, weakref
  File "/usr/lib/python2.7/os.py", line 119, in <module>
    sys.modules['os.path'] = path
AttributeError: 'module' object has no attribute 'modules'

I do not have the time to debug this, but feel free to for this or send me a PR. I guess one can still reuse the ast mutations and probably the import mechanisms.