????Python ?????????????????????????????????????????????????????????ó???**?????????????????????????????????
????????????????? Python ??????? ?????????? ?????????????е? ???????? ?????? zope.testing??py.test ?? nose???????????????? Python ?????д???????????????????????ε?????????????????????????з??????????????????в???????????????????????????????????ò????????????????
????Python ??????????
????Python ??????????????????????????????????????????????????? Python ????б?д????????????д?????? test_all.py ?? tests.py ???????????????????????????в????????????????????????????????????????????????????????????????????????????????????????????????????ε?????????????? Python ????????????????????????????????????????????
????test_all.py??????????????????????????????????????????????????????·?????????????е?????б????????????????????????????μ??????????????????????????????????????????У???????? Python ????????????????β??????????????
?????????????????????????????????????????????????????????????????????????????С?????? Python ?????????Щ Python ??????????????????????????
# test_old.py - The old way of doing things
import unittest
class TruthTest(unittest.TestCase):
def testTrue(self):
ass** True == 1
def testFalse(self):
ass** False == 0
if __name__ == '__main__':
unittest.main()
????????е? ???????? ???????????? TestCase ?????????????????????????????????????????????????У????????????????????????????????????е?????????? test_old.py ???????????????£???????????? unittest ??????????????????????????????????????????????????????????????????????Χ??????????????С?
???????????????????????????????и??????????????鷳??????????????????????????????????????????? test_main() ?????????????????????????????????????????????????????????????????????????????????????????????????????з?????????в???
????Python ???????????
???????????? Python ???????????????????????????????????????????????Щ????????????????
????????????????????????????????????????в????????????????????? Python ???????????????????????????????
????zope.testing ?????в??????????????????? Zope ?????????????? buildout ????????????????????? buildout.cfg ????е? zc.recipe.testrunner recipe ??????????????????????????????????£?????????????? Zope ????У????? buildout ????????? ./bin/test ???????????????????????????
????py.test ?? nose ???????????????????????????????й????????????????????????????????????
????# Run "py.test" on the project
????# in the current directory...
????$ py.test
????# Run "nose" on the project
????# in the current directory...
????$ nosetests
????py.test ?? nosetests ?????????м????????????????????? -v ???????в???????????????????????????????????????????????????????д???????? Python ????????
????????????к???????????????????? Python ???????????а?????? setup.py ???????????????????
????# Common commands supported by setup.py files
????$ python setup.py build
????$ python setup.py install
???????????? Python ?????? setuptools ??????? Python ??????? setup.py ????????????????????в???? test ????
????# If a project's setup.py uses "setuptools"
????# then it will provide a "test" command too
????$ python setup.py test
????????????????Σ?????????????μ?????? setup.py test?????????????????????????????? Python ????????????nose ??????????????? setup.py?????????????? nosetests ?????????????????????
# A setup.py file that uses "nose" for testing
from setuptools import setup
setup(
# ...
# package metadata
# ...
setup_requires = ['nose']??
test_suite = 'nose.collector'??
)
??????????????????? setup.py ?????????????????????????? nosetests????? nosetests ????????????????????????μ???????????????????? bug ????????????????????????????????????????? test_suite ??????????????