dut.py 我們所寫好的 method
""" dut """ __all__ = ['frame'] class frame(object): def __init__(self): self.name = "frame" def double(self,w): return w * 2 def triple(self,w): return w * 3test_dut.py 測試寫的 method
import os import unittest import nose from dut import * import gc class TestDouble(unittest.TestCase): def setUp(self): self.frame = frame() def teardown(self): self.frame = None gc.collect() @unittest.skip("calling test skip test_double_word") def test_double_word(self): """ test double word """ expect = "hihi" results = self.frame.double("hi") self.assertTrue(expect == results) def test_double_dec(self): """ test double dec """ expect = 4.0 results= self.frame.double(2.0) self.assertTrue(expect == results) if __name__ == '__main__': # unittest.main() import nose # nose.runmodule(argv=[__file__,'-vvs','-x', '--ipdb-failure'], # exit=False) nose.runmodule(argv=[__file__,'-vvs','-x','--pdb', '--pdb-failure'], exit=False)__init__.py path include
runtest.sh top test run manager
#!/bin/sh coverage erase nosetests -w ./ --with-coverage --cover-package=dut $*
how to run it
>>> ./runtest.sh
test results
>>> results .S ---------------------------------------------------------------------- Ran 2 tests in 0.001s OK (SKIP=1)
怎格式都跑掉了....真是麻煩.就先頂一下的用吧
回覆刪除