Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Making errors eclipse-friendly
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andrea Crotti  
View profile  
 More options Jan 16 2012, 10:31 am
From: Andrea Crotti <andrea.crott...@gmail.com>
Date: Mon, 16 Jan 2012 15:31:26 +0000
Local: Mon, Jan 16 2012 10:31 am
Subject: Making errors eclipse-friendly
I have to integrate nose output with Eclipse.
It would be maybe nicer to find a way to integrate PyDev but since it
looks way more complicated
and not everyone is using PyDev here, I think I have to stick with a
more hand-made thing.

What I need is very simple, output for every error something that
Eclipse is able to parse in the form
for example filename:line.

I didn't find any doc about how to do these kind of things, so I started
to do something like this:

class MyRunner(object):
     def egg_runner(self, eggpath):
         conf = Config()
         conf.verbosity = 3
         eclipse_runner = EclipseFriendlyRunner(stream=conf.stream,

verbosity=conf.verbosity,  # why should I pass the config too in theory??
                                                config=conf
                                           )
         # and with this the verbosity should be set correctly
         TestProgram(argv=argv[:1], config=conf, defaultTest=eggpath,
                     testRunner=eclipse_runner)

class EclipseFriendlyRunner(TextTestRunner):

     def _makeResult(self):
         return EclipseFriendlyResult(self.stream,
                                      self.descriptions,
                                      self.verbosity,
                                      self.config)

class EclipseFriendlyResult(TextTestResult):

     def addError(self, test, err):
         print("this is from my eclipse friendly runner")
         super(EclipseFriendlyResult, self).addError(test, err)

But my print statement is never called even in case of errors.
Anyway in general does it make sense what I'm doing?
Seems that overriding _makeResult should not be a good thing to do,
but I didn't see anything better..

And another question, has the API been stable enough through versions
(past and future) or I am going to run into troubles?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrea Crotti  
View profile   Translate to Translated (View Original)
 More options Jan 16 2012, 10:47 am
From: Andrea Crotti <andrea.crott...@gmail.com>
Date: Mon, 16 Jan 2012 15:47:31 +0000
Local: Mon, Jan 16 2012 10:47 am
Subject: Re: Making errors eclipse-friendly
On 01/16/2012 03:31 PM, Andrea Crotti wrote:

> I have to integrate nose output with Eclipse.
> It would be maybe nicer to find a way to integrate PyDev but since it
> looks way more complicated
> and not everyone is using PyDev here, I think I have to stick with a
> more hand-made thing.

> What I need is very simple, output for every error something that
> Eclipse is able to parse in the form
> for example filename:line.
> ...

 From some analysis looks like it's not a great idea, I probably should
write a plugin and enable it,
is that right?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrea Crotti  
View profile  
 More options Jan 16 2012, 11:51 am
From: Andrea Crotti <andrea.crott...@gmail.com>
Date: Mon, 16 Jan 2012 16:51:15 +0000
Local: Mon, Jan 16 2012 11:51 am
Subject: Re: Making errors eclipse-friendly
On 01/16/2012 03:47 PM, Andrea Crotti wrote:

> From some analysis looks like it's not a great idea, I probably should
> write a plugin and enable it,
> is that right?

I'm trying to write my own plugin and looking here and there I get the
following (at the moment).
The thing is that I'm not quite sure how to enable it, and how to get
the output of the plugin to
substitute the normal output.

For example xunit only allows to write on a separate file and the output
remains untouched,
so how do I just susbtitute the default formatter in general?

class EclipseFriendlyPlugin(Plugin):
     """Nose plugin to output errors in a format that is easily parsable
by Eclipse
     """

     name = 'eclipse_friendly'
     encoding = 'UTF-8'

     def __init__(self):
         self.errorlist = []
         super(EclipseFriendlyPlugin, self).__init__()

     def _format_error(self, level, test, err):
         fname, lineno = _location_from_traceback(err)
         return "%s %s: (%s:%d)" % (level, test.id(), fname, lineno)

     def options(self, parser, env=os.environ):
         super(EclipseFriendlyPlugin, self).options(parser, env=env)

     def configure(self, options, config):
         """Configures the xunit plugin."""
         Plugin.configure(self, options, config)
         self.config = config
         if self.enabled:
             self.stats = {
                 'errors': 0,
                 'failures': 0,
                 'passes': 0,
                 'skipped': 0
             }

     def addError(self, test, err, capt=None):
         if issubclass(err[0], SkipTest):
             err_type = 'skipped'
             self.stats['skipped'] += 1
         else:
             err_type = 'error'
             self.stats['errors'] += 1

         self.errorlist.append(self._format_error("error", test, err))

     def addFailure(self, test, err):
         self.stats['failures'] += 1
         msg = self._format_error("failure", test, err)
         self.errorlist.append(msg)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrea Crotti  
View profile  
 More options Jan 17 2012, 10:40 am
From: Andrea Crotti <andrea.crott...@gmail.com>
Date: Tue, 17 Jan 2012 15:40:04 +0000
Local: Tues, Jan 17 2012 10:40 am
Subject: Re: Making errors eclipse-friendly
I cleaned up the code a little bit, and here it's what it looks like.
I don't actually want to add options to the option parser or any other
fancy thing,
I just want to make sure that this plugin is enabled and the default output
is substituted with the one given by this plugin.

I can't find, however, a single helpful example or a hint about how to do it
(and I would be pleased to share my code in the nose website when it's
working).

Any suggestions?

class NoseTestRunner(object):
     def egg_runner(self, eggpath):
         """Run all the tests in the given egg
         """
         conf = Config()
         conf.verbosity = 3
         ep = EclipseFriendlyPlugin()
         # how do I make sure the plugin is actually loaded and doing
something?
         ep.enabled = True
         # how do I actually enable it?
         plugins = [ep]
         # and with this the verbosity should be set correctly
         # should use addplugins instead if they are not "default" plugins
         TestProgram(argv=argv[:1], config=conf, defaultTest=eggpath,
                     plugins=plugins)

class EclipseFriendlyPlugin(Plugin):
     """Nose plugin to output errors in a format that is easily parsable
by Eclipse
     """

     name = 'eclipse_friendly'
     encoding = 'UTF-8'

     def __init__(self):
         self.errorlist = []
         self.successlist = []
         super(EclipseFriendlyPlugin, self).__init__()

     def _format_error(self, level, test, err):
         fname, lineno = _location_from_traceback(err)
         return "%s %s: (%s:%d)" % (level, test.id(), fname, lineno)

     def options(self, parser, env=os.environ):
         super(EclipseFriendlyPlugin, self).options(parser, env=env)

     def configure(self, options, config):
         """Configures the xunit plugin."""
         Plugin.configure(self, options, config)

     def addError(self, test, err, capt=None):
         # if returning something other plugins will not see the error
raised
         self.errorlist.append(self._format_error("error", test, err))

     def addFailure(self, test, err):
         self.errorlist.append(self._format_error("failure", test, err))

     def addSuccess(self, test):
         self.successlist.append(test.id())

     def report(self, stream):
         # should I force the unicode here too maybe or not care about it?
         for error in self.errorlist:
             stream.writeln(error)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrea Crotti  
View profile  
 More options Jan 18 2012, 11:06 am
From: Andrea Crotti <andrea.crott...@gmail.com>
Date: Wed, 18 Jan 2012 16:06:17 +0000
Local: Wed, Jan 18 2012 11:06 am
Subject: Re: Making errors eclipse-friendly
Simplifying the question a bit..
Given a plugin I think that the right thing to do to enable it would be
to use addplugins

         ep = EclipseFriendlyPlugin()
         # how do I make sure the plugin is actually loaded and doing
something?
         plugins = [ep]
         # and with this the verbosity should be set correctly
         # should use addplugins instead if they are not "default" plugins
         TestProgram(argv=argv[:1], config=conf, defaultTest=eggpath,
                     addplugins=plugins)

but it doesn't work, I get a :
   File "/home/andrea/.local/bin/run_tests", line 9, in <module>
     load_entry_point('psi.devsonly==0.1', 'console_scripts', 'run_tests')()
   File
"/home/andrea/git_projs/Psi/psi.devsonly/psi/devsonly/bin/run_tests.py",
line 62, in main
     modes[ns.mode]()
   File
"/home/andrea/git_projs/Psi/psi.devsonly/psi/devsonly/bin/run_tests.py",
line 42, in simple
     print(NoseTestRunner().egg_runner(ns.project_path))
   File
"/home/andrea/git_projs/Psi/psi.devsonly/psi/devsonly/testwrapper.py",
line 60, in egg_runner
     addplugins=plugins)
   File "/usr/lib/python2.7/site-packages/nose/core.py", line 107, in
__init__
     config.plugins.addPlugins(addplugins)
   File "/usr/lib/python2.7/site-packages/nose/plugins/manager.py", line
208, in addPlugins
     raise NotImplementedError()
NotImplementedError

I guess that with another PluginManager it might work, but I have no way
apparently to the way
the pluginmanager is actually chosen, am I wrong??

If instead I pass
"plugins=plugins", everything seems fine but the plugin seems to have no
effect whatsoever...

Any hint how to just make a plugin working by default and writing output
on the console??


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jason pellerin  
View profile  
 More options Jan 23 2012, 3:22 pm
From: jason pellerin <jpelle...@gmail.com>
Date: Mon, 23 Jan 2012 15:22:15 -0500
Local: Mon, Jan 23 2012 3:22 pm
Subject: Re: [nose-users] Re: Making errors eclipse-friendly
addplugins is the right way to do this -- the error you're seeing
there is because somehow you've got the "NoPlugins" plugin manager
enabled. You should see good results from using the default plugin
manager and addplugins.

JP

On Wed, Jan 18, 2012 at 11:06 AM, Andrea Crotti


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrea Crotti  
View profile  
 More options Jan 24 2012, 5:51 am
From: Andrea Crotti <andrea.crott...@gmail.com>
Date: Tue, 24 Jan 2012 10:51:00 +0000
Subject: Re: [nose-users] Re: Making errors eclipse-friendly
On 01/23/2012 08:22 PM, jason pellerin wrote:

> addplugins is the right way to do this -- the error you're seeing
> there is because somehow you've got the "NoPlugins" plugin manager
> enabled. You should see good results from using the default plugin
> manager and addplugins.

> JP

Good thanks I think I solved this by the way, I was passing
a configuration to increase the verbosity as
conf= Config()
conf.verbosity = 3

So the question is, how do I create a configuration which doesn't
interfere with the addplugins?

(because in Config actually plugins is set to NoPluginManager, which
explains everything).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrea Crotti  
View profile  
 More options Jan 24 2012, 8:02 am
From: Andrea Crotti <andrea.crott...@gmail.com>
Date: Tue, 24 Jan 2012 13:02:53 +0000
Local: Tues, Jan 24 2012 8:02 am
Subject: Re: [nose-users] Re: Making errors eclipse-friendly
On 01/24/2012 10:51 AM, Andrea Crotti wrote:

> Good thanks I think I solved this by the way, I was passing
> a configuration to increase the verbosity as
> conf= Config()
> conf.verbosity = 3

> So the question is, how do I create a configuration which doesn't
> interfere with the addplugins?

> (because in Config actually plugins is set to NoPluginManager, which
> explains everything).

And another thing, which was the older way of doing the same?
Because actually addplugins is not present in the version I have on
windows (0.10)..

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »