tag:blogger.com,1999:blog-9238405.post110685751430406239..comments2024-03-18T02:04:50.380-07:00Comments on Agile Testing: Python unit testing part 1: the unittest moduleGrig Gheorghiuhttp://www.blogger.com/profile/17863511617654196370noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-9238405.post-33394494952755281262014-09-24T12:24:46.795-07:002014-09-24T12:24:46.795-07:00def tearDown(self):
if self.failed:
return
...def tearDown(self):<br /> if self.failed:<br /> return<br /> duration = time.time() - self.startTime_<br /> self.cleanup(True)<br /> if self.reportStatus_:<br /> #self.log.info("=== Test %s completed normally (%d sec)", self.name_, duration<br /><br />I tried to use this code on tearDown() but it shows me exception on invalid syntax in I guess it is due to time function I have import the library even though why this syntax error is showing please suggest and help.Anonymoushttps://www.blogger.com/profile/05108331153037861376noreply@blogger.comtag:blogger.com,1999:blog-9238405.post-45237470993645057422014-06-19T16:38:48.321-07:002014-06-19T16:38:48.321-07:00If you use a nice test runner like Green, you can ...If you use a nice test runner like Green, you can omit the entire if..."__main__": section of the code. (Full disclosure, I wrote Green) https://github.com/CleanCut/greenAnonymoushttps://www.blogger.com/profile/10397863074809131428noreply@blogger.comtag:blogger.com,1999:blog-9238405.post-55422605780037850622013-08-21T07:28:31.513-07:002013-08-21T07:28:31.513-07:00It is 2013. This is the first example of unittest ...It is 2013. This is the first example of unittest in Python that I have actually understood. I now actually understand where everything is supposed to be placed when creating test suites. Thank you, a million times over, thank you!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9238405.post-53046678111907335822012-06-27T15:08:22.840-07:002012-06-27T15:08:22.840-07:00Shouldn't tests be independent of one another,...Shouldn't tests be independent of one another, hence the order in which they're run should not matter?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9238405.post-44952357934678908912011-01-15T09:17:54.879-08:002011-01-15T09:17:54.879-08:00I see you used both unittest and doctest together ...I see you used both unittest and doctest together in your example, but when does one choose a particular testing framework over another? Coming from Java land, JUnit seems to be the defacto for Java.<br /><br />Is there something like that for Python?<br /><br />Nice article BTW :)Evanshttp://jroller.com/evansnoreply@blogger.comtag:blogger.com,1999:blog-9238405.post-39854087079684876572009-12-06T14:33:14.054-08:002009-12-06T14:33:14.054-08:00Grig,
Needed to refer back to this today (2009). ...Grig,<br />Needed to refer back to this today (2009). Never gets old. Thanks.<br />Carl T.Carl Trachtehttps://www.blogger.com/profile/12363048245012413049noreply@blogger.comtag:blogger.com,1999:blog-9238405.post-60604147004958089642008-11-29T08:16:00.000-08:002008-11-29T08:16:00.000-08:00Very interesting article, congratulations. Just wh...Very interesting article, congratulations. Just what I neededAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-9238405.post-32552272858727085162007-08-06T09:40:00.000-07:002007-08-06T09:40:00.000-07:00Cons: tests are executed in alphanumerical orderSo...Cons: tests are executed in alphanumerical order<BR/><BR/>So naming them <BR/>test_01_<real_name><BR/>test_02_<real_name2> ...<BR/><BR/>forces unittest executing tests in defined and easy modificable order. I'm used to do so.<BR/><BR/>Just my 5 cents<BR/><BR/>Facility to run test in defined order, but break the run after first failed test lacks to me in unittest. I know how to do it (runnig each test namelly and testing its result) but I don't like it and it's hard to extend.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9238405.post-1119726338047831092005-06-25T12:05:00.000-07:002005-06-25T12:05:00.000-07:00Consider using TestOOB (http://testoob.sourceforge...Consider using TestOOB (http://testoob.sourceforge.net) which extends Python's unittest module capabilities.<BR/><BR/>Any unittest/doctest suites work without changes, and it's got some really cool features, like color console output, xml/html reports, and firing up pdb on failed tests.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9238405.post-1106937745088541122005-01-28T10:42:00.000-08:002005-01-28T10:42:00.000-08:00Great! Especially looking forward to the part on ...Great! Especially looking forward to the part on "py.test", what I have seen so far about "py.test" looks very good.<br /><br />Currently I am using unittest and doctest together (verifying my docstrings becomes one of my unittest tests). Each test gets put into the place where it feels more natural, usually doctest, but if a testing framework is required (loops, setup, teardown, etc.), it goes into unittest, instead of fussing with doctest.Anonymousnoreply@blogger.com