Search This Blog

Tuesday, May 07, 2013

error in setup.cfg: command 'nosetests' has no such option 'with_pylons'

When running nosetests, if you see error in setup.cfg: command 'nosetests' has no such option 'with_pylons' or Error reading config file 'setup.cfg': no such option 'with-pylons', it could be because you have Pylons==1.0* installed. Pylons==1.0* does not register itself as a nose plugin (https://github.com/Pylons/pylons/issues/13). Use following work arounds:
  1. For "python setup.py nosetests":
    Add the following to your projects "setup.py -> entry_points" and ".egg-info/entry_points.txt"
        [nose.plugins]
        pylons = pylons.test:PylonsPlugin
    
  2. For "nosetests --version":
    sudo vim `which nosetests`
    
    Make it look something like:
    #!/usr/bin/python
    # EASY-INSTALL-ENTRY-SCRIPT: 'nose==1.3.0','console_scripts','nosetests'
    __requires__ = 'nose==1.3.0'
    import sys
    from pkg_resources import load_entry_point
    
    addplugins = []
    
    try:
        import pylons
        if pylons.__version__[0] == '1':
            from pylons.test import PylonsPlugin
            addplugins.append(PylonsPlugin())
    except ImportError:
        pass
    
    if __name__ == '__main__':
        sys.exit(
            load_entry_point('nose==1.3.0', 'console_scripts', 'nosetests')(addplugins=addplugins)
        )
    
    now you should be able to run it as nosetests --version

No comments: