Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; '__name__': 0.07; 'unittest': 0.07; 'fails.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; 'def': 0.10; "'__main__':": 0.16; 'message-id:@dough.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'tests': 0.18; 'import': 0.21; 'exceptions': 0.22; 'runs': 0.22; 'dependent': 0.23; 'raise': 0.24; 'second': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'done.': 0.27; 'separate': 0.27; 'header:X-Complaints-To:1': 0.28; 'run': 0.28; 'assert': 0.29; 'catching': 0.29; 'class': 0.29; 'point': 0.31; 'could': 0.32; 'to:addr:python-list': 0.33; 'false': 0.35; 'received:org': 0.36; 'method': 0.36; 'test': 0.36; 'problems': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'skip:u 10': 0.60; 'first': 0.61; 'within': 0.64; 'andrea': 0.84; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: assertraises behaviour Date: Tue, 17 Jul 2012 14:39:12 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342550377 news.xs4all.nl 6887 [2001:888:2000:d::a6]:41360 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25532 On 7/17/2012 5:06 AM, andrea crotti wrote: > Well this is what I meant: > > import unittest > > class TestWithRaises(unittest.TestCase): > def test_first(self): > assert False > > def test_second(self): > print("also called") > assert True > > if __name__ == '__main__': > unittest.main() > > in this case also the second test is run even if the first fails. Or test_first is run even if test_second fails. The point is that unittest runs separate test methods independently. They could theoretically be run simultaneously. Tests within a method are dependent unless you take steps to make them independent by not having them raise exceptions or by catching exception as you go until you are done. If you make a error_list of problems as you go, you could end the method with assertFalse(error_list). -- Terry Jan Reedy