Ńņ
ā÷Gc
@ s
d Z d d k Z d d k Z d d k l Z y d d k l Z Wn# e j
o d d k l Z n Xd d g Z d e f d YZ
d e f d YZ d
Z d Z
d Z d
Z d Z d Z d Z e d j o d d k Z e i n d S( s>
Plugin tester
-------------
Utilities for testing plugins.
i’’’’N( t warn( t StringIOt PluginTestert runc B sS e Z d Z d Z d Z d Z h Z d Z g Z d Z
d Z d Z d Z
RS( sz A mixin for testing nose plugins in their runtime environment.
Subclass this and mix in unittest.TestCase to run integration/functional
tests on your plugin. When setUp() is called, the stub test suite is
executed with your plugin so that during an actual test you can inspect the
artifacts of how your plugin interacted with the stub test suite.
Class Variables
---------------
- activate
- the argument to send nosetests to activate the plugin
- suitepath
- if set, this is the path of the suite to test. otherwise, you
will need to use the hook, makeSuite()
- plugins
- the list of plugins to make available during the run. Note
that this does not mean these plugins will be *enabled* during
the run -- only the plugins enabled by the activate argument
or other settings in argv or env will be enabled.
- args
- a list of arguments to add to the nosetests command, in addition to
the activate argument
- env
- optional dict of environment variables to send nosetests
c C s
t d S( s» returns a suite object of tests to run (unittest.TestSuite())
If self.suitepath is None, this must be implemented. The returned suite
object will be executed with all plugins activated. It may return
None.
Here is an example of a basic suite object you can return ::
>>> import unittest
>>> class SomeTest(unittest.TestCase):
... def runTest(self):
... raise ValueError("Now do something, plugin!")
...
>>> unittest.TestSuite([SomeTest()]) # doctest: +ELLIPSIS
]>
N( t NotImplementedError( t self( ( s; /usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt makeSuiteA s c C sŻ d d k l } d d k l } d d k l } d } t } | d | i d | d | d | i } | i
d j o | i
| _
n | i p | i } n | d | i
d | d
| d t | _ t | | _ d S(
s7 execute the plugin on the internal test suite.
i’’’’( t Config( t TestProgram( t
PluginManagert envt streamt pluginst argvt configt suitet exitN( t nose.configR t nose.coreR t nose.plugins.managerR t NoneR R
R t ignoreFilest suitepathR R
t Falset noset AccessDecoratort output( R R R R R R t conf( ( s; /usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt _execPluginU s
c C sb d | i g | _ | i o | i i | i n | i o | i i | i n | i d S( sV runs nosetests with the specified test suite, all plugins
activated.
t nosetestsN( t activateR
t argst extendR t appendR ( R ( ( s; /usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt setUpj s
N( t __name__t
__module__t __doc__R R R R R
R
R R R R R" ( ( ( s; /usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyR s # R c B s8 e Z d Z d Z d Z d Z d Z d Z RS( c C s6 | | _ | i d | i | _ | i d d S( Ni ( R t seekt readt _buf( R R ( ( s; /usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt __init__z s
c C s
| | i j S( N( R( ( R t val( ( s; /usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt __contains__ s c C s | i S( N( R ( R ( ( s; /usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt __iter__ s c C s | i S( N( R( ( R ( ( s; /usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt __str__ s N( R# R$ R R R( R) R+ R, R- ( ( ( s; /usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyR w s c c so g } xI | i t D]8 } | i | | i p d i | Vg } q q W| o d i | Vn d S( Nt ( t
splitlinest TrueR! t stript join( t textt blockt line( ( s; /usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt blankline_separated_blocks s
c C sf t i d t i t i Bt i B } g } x- t | D] } | i | i d | q6 Wd i | S( Nsß
# Grab the traceback header. Different versions of Python have
# said different things on the first traceback line.
^(?P Traceback\ \(
(?: most\ recent\ call\ last
| innermost\ last
) \) :
)
\s* $ # toss trailing whitespace on the header.
(?P .*?) # don't blink: absorb stuff until...
^ (?P \w+ .*) # a line *starts* with alphanum.
s \g\n...\n\gR. ( t ret compilet VERBOSEt MULTILINEt DOTALLR6 R! t subR2 ( t outt traceback_ret blocksR4 ( ( s; /usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt remove_stack_traces s
c C s, t i d t i t i B } | i d | S( Nsü
# Cut the file and line no, up to the warning name
^.*:\d+:\s
(?P\w+): \s+ # warning category
(?P.+) $ \n? # warning message
^ .* $ # stack frame
s \g: \g( R7 R8 R9 R: R<