dimanche 28 décembre 2014

how to test the Fixture Class explicitily?

I was trying to ensure the fixture reset the state but now I am asked to test the fixture class explicitly !!! I am not sure what does that mean when doing the strategy below is reset the state



import sys
import testtools
import fixtures

class MyTestExample_Fixture(fixtures.Fixture):
"""docstring for MyTestExample_Fixture"""
def setUp(self):
super(MyTestExample_Fixture, self).setUp()
print >> sys.stderr, "ran Fixture"
print >> sys.stderr, "state Reset"


class MyTestExample(testtools.TestCase):
"""docstring for MyTestExample"""

def setUp(self):
super(MyTestExample, self).setUp()
self.useFixture(MyTestExample_Fixture())
print >> sys.stderr, "setUp"

def test_1(self):
print >> sys.stderr, "test_1"

def test_2(self):
print >> sys.stderr, "test_2"

$python -m nose.core testExample.py
### the result:

ran Fixture
state Reset
setUp
test_1
.ran Fixture
state Reset
setUp
test_2
.
----------------------------------------------------------------------
Ran 2 tests in 0.001s

OK

Aucun commentaire:

Enregistrer un commentaire