Why doesn't nose see my plugin?


R

Roy Smith

I'm attempting to write a nose plugin. Nosetests (version 1.3.0) is not
seeing it. I'm running python 2.7.3. The plugin itself is:

mongo_reporter.py:
------------------------------------------------
import nose.plugins
import logging

log = logging.getLogger('nose.plugins.mongoreporter')

class MongoReporter(nose.plugins.Plugin):
name = "Mongo Reporter"

def options(self, parser, env):
super(MongoReporter, self).options(parser, env=env)

def configure(self, options, conf):
super(MongoReporter, self).options(options, conf)

def finalize(self, result):
log.info("Hello from Mongo Reporter")
------------------------------------------------

I also have setup.py:

------------------------------------------------
#!/usr/bin/env python

from setuptools import setup, find_packages

setup(
name = "Mongo Reporter",
version = "0.0",
entry_points = {
'nose.plugins.1.10': ['mongoreporter =
mongo_reporter.MongoReporter'],
},
)
------------------------------------------------

$ ./setup.py develop
running develop
running egg_info
writing Mongo_Reporter.egg-info/PKG-INFO
writing top-level names to Mongo_Reporter.egg-info/top_level.txt
writing dependency_links to Mongo_Reporter.egg-info/dependency_links.txt
writing entry points to Mongo_Reporter.egg-info/entry_points.txt
reading manifest file 'Mongo_Reporter.egg-info/SOURCES.txt'
writing manifest file 'Mongo_Reporter.egg-info/SOURCES.txt'
running build_ext
Creating
/home/roy/deploy/current/python/lib/python2.7/site-packages/Mongo-Reporte
r.egg-link (link to .)
Mongo-Reporter 0.0 is already the active version in easy-install.pth

Installed /home/roy/deploy/current/code/testing/nose
Processing dependencies for Mongo-Reporter==0.0
Finished processing dependencies for Mongo-Reporter==0.0


$ nosetests --plugins
Plugin capture
Plugin failuredetail
Plugin xunit
Plugin deprecated
Plugin skip
Plugin multiprocess
Plugin logcapture
Plugin coverage
Plugin attributeselector
Plugin doctest
Plugin profile
Plugin id
Plugin allmodules
Plugin collect-only
Plugin isolation
Plugin pdb

I'm not really familiar with setuptools, so I don't know if I've got a
"I'm doing something with nose" issue or a "I'm doing something wrong
with setuptools" issue.
 
Ad

Advertisements

A

alex23

I'm attempting to write a nose plugin.  Nosetests (version 1.3.0) is not
seeing it.

setup(
    entry_points = {
        'nose.plugins.1.10': ['mongoreporter =
mongo_reporter.MongoReporter'],
        },

Hey Roy,

I've never actually written a nose plugin so this is a wild stab in
the dark, but should the entry point be 'nose.plugins.1.3.0' in order
to reflect the version of nose?
 
R

Roy Smith

alex23 said:
I'm attempting to write a nose plugin.  Nosetests (version 1.3.0) is not
seeing it.

setup(
    entry_points = {
        'nose.plugins.1.10': ['mongoreporter =
mongo_reporter.MongoReporter'],
        },

Hey Roy,

I've never actually written a nose plugin so this is a wild stab in
the dark, but should the entry point be 'nose.plugins.1.3.0' in order
to reflect the version of nose?

I took the above directly from the example in
https://nose.readthedocs.org/en/latest/plugins/writing.html

Just to see what would happen, I tried changing it to:

entry_points = {
'nose.plugins.1.3.0': ['mongoreporter =
testing.nose.mongo_reporter.MongoReporter'],
},

didn't appear to make any difference. I'm still trying to wrap my head
completely around setuptools. I haven't fully figured out how the entry
points stuff works.
 
A

alex23

Just to see what would happen, I tried changing it to:

    entry_points = {
        'nose.plugins.1.3.0': ['mongoreporter =
testing.nose.mongo_reporter.MongoReporter'],
        },

didn't appear to make any difference.

Yeah, reading some more it looks like it's referring to the version of
the plugin API and not of nose itself, sorry for the mislead.
 
R

Roy Smith

alex23 said:
Just to see what would happen, I tried changing it to:

    entry_points = {
        'nose.plugins.1.3.0': ['mongoreporter =
testing.nose.mongo_reporter.MongoReporter'],
        },

didn't appear to make any difference.

Yeah, reading some more it looks like it's referring to the version of
the plugin API and not of nose itself, sorry for the mislead.

Thanks anyway.

In the meantime, I've worked around the problem by puttingL

if __name__ == '__main__':
nose.main(addplugins=[MongoReporter()])

in my test file, so at least the setuptools issue isn't a blocker for
continuing to work on the plugin.
 
R

Roy Smith

Roy Smith said:
setup(
name = "Mongo Reporter",
version = "0.0",
entry_points = {
'nose.plugins.1.10': ['mongoreporter = mongo_reporter.MongoReporter'],
},
)

The problem turned out to be the syntax of the entry_point
declaration. It should have been "mongo_reporter:MongoReporter"
(colon, not dot, delimiting the module from the class).

Still strugging to get my head fully around setuptools :)
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top