If I invoke a test script say
nosetests -a tag1='one'
is there a way to print the user input of tag1
in my script?
@attr(tag1=['one', 'two', 'three', 'four'])
def test_real_logic(self):
#how to print the user input here
If I invoke a test script say
nosetests -a tag1='one'
is there a way to print the user input of tag1
in my script?
@attr(tag1=['one', 'two', 'three', 'four'])
def test_real_logic(self):
#how to print the user input here
Not without some pain.
self.test_real_logic.tag1
should give you all the attributes attached to the function. They are stored as a dictionary within__dict__
attribute of the test function. Fortest_real_logic.tag1
it would be['one', 'two', 'three', 'four'].
If you do not want to hard code function name, you cad try extract the dictionary by doing something like:
Now you would have to iterate over local attributes and compare them with the system arguments for a match and print the attributes that are common, similar to what attribute plugin already does. Or you can slightly modify the existing
attrib
plugin methodvalidateAttrib
so that it adds a matching attribute to the list of attributes, something like this (inLib/site-packages/nose/plugins/attrib.py
):This way your
self.test_real_logic
will have two additional attributesmatched_key=tag1
andmatched_value=one
that you can access similarly astag1
attribute.