[Chennaipy] overriding default nose-loader

vijayram vijayram.gopu at gmail.com
Fri Oct 2 21:53:11 CEST 2015


Hi All,

 I am trying to bypass nose's default loading of test-cases, by asking it to pick up testcase from the module I specify.. I read through the docmentation, few sample plugins like isolation and doctests, I am kind of lost...  if someone has an insight into it, much appreciated... 

approach i took,

* save a reference to the core test loader in prepareTestLoader()
* override implement loadTestsFromModule(module), it loads tests from a specific module then do:
    yield self.loader.loadTestsFromModule(extension_module)

Questions and issues I am facing,
1. Can I set the loader.suiteClass in the prepareTestLoader itself.. or do I need to explicitly override loadTestsFromModule function...

2. What should I do in the loadTestsFromModule, yield or return, at some places we are yielding suiteClass and at some places we are returning suiteClass, so confused what is the right behavior.. looking at examples I tried following below, what is right,

   yield self.loader.loadTestsFromModule(extension_module)
   return self.loader.loadTestsFromModule(extension_module)
   yield self.suiteClass(self.loader.loadTestsFromModule(extension_module))
   return self.suiteClass(self.loader.loadTestsFromModule(extension_module))

Issues,

    when I used self.loader.loadTestsFromModule(extension_module); I am getting below error,
  File "/opt/tools/lib/python2.7/site-packages/nose/suite.py", line 218, in run

    if result.shouldStop:

  File "/opt/tools/lib/python2.7/site-packages/nose/proxy.py", line 30, in fget

    return getattr(getattr(self, local_attr), proxied_attr)

AttributeError: 'ContextList' object has no attribute 'shouldStop'



     alternatively I used: nose.loader.TestLoader().loadTestsFromModule(module=mod1)


These are my plugin-functions below for your reference,

   def prepareTestLoader(self, loader):
        print "--- prepareTestLoader.."

        self.loader = loader

        self.suiteClass = loader.suiteClass

        suite = nose.loader.TestLoader().loadTestsFromModule(module=mod1)

        loader.suiteClass = self.loader.suiteClass(suite)   <---- can I do this, am getting errors

        
    def loadTestsFromModule(self, module=None):

        print "Into... loadTestsFromModule.."

        #suite = nose.loader.TestLoader().loadTestsFromModule(module=mod1)

        suite = self.loader.loadTestsFromModule(module=mod1)


        yield self.loader.suiteClass(suite)



Thank you so much ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chennaipy/attachments/20151002/69146343/attachment.html>


More information about the Chennaipy mailing list