mkwiatkowski / pinocchio

pinocchio is a set of extensions to the nose unit testing framework for Python
38 stars 13 forks source link

Allows attributes with values #20

Closed little-dude closed 9 years ago

little-dude commented 9 years ago

We can now give values to the attributes with the following syntax : mymodule.MyTestClass.my_test_method: attr=attr_value

I also updated the example.

# examples/test_decorator.attribs
test_decorator.TestMeWithValues: runlevel=default
test_decorator.TestMeWithValues.test_me_runlevel_quick: runlevel=quick
test_decorator.TestMeWithValues.test_me_runlevel_express: runlevel=express
test_decorator.TestMeWithValues.test_me_runlevel_extensive: runlevel=extensive
# examples/test_decorator.py
class TestMeWithValues:
    def test_me_runlevel_default(self):
        print "Running test_me_runlevel_default"

    def test_me_runlevel_quick(self):
        print "Running test_me_runlevel_quick"

    def test_me_runlevel_express(self):
        print "Running test_me_runlevel_express"

    def test_me_runlevel_extensive(self):
        print "Running test_me_runlevel_extensive"

Output :

(env2)./~pinocchio git:namedattr ❯❯❯ nosetests --decorator-file examples/test_decorator.attribs examples/test_decorator.py -a runlevel=default -s
Running test_me_runlevel_default
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
(env2)./~pinocchio git:namedattr ❯❯❯ nosetests --decorator-file examples/test_decorator.attribs examples/test_decorator.py -a runlevel=quick -s
Running test_me_runlevel_quick
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
(env2)./~pinocchio git:namedattr ❯❯❯ nosetests --decorator-file examples/test_decorator.attribs examples/test_decorator.py -a runlevel=express -s
Running test_me_runlevel_express
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
(env2)./~pinocchio git:namedattr ❯❯❯ nosetests --decorator-file examples/test_decorator.attribs examples/test_decorator.py -a runlevel=extensive -s
Running test_me_runlevel_extensive
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
mkwiatkowski commented 9 years ago

Cool feature, thanks for the PR.