Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '(so': 0.07; 'tests.': 0.07; '__name__': 0.09; 'messing': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:test': 0.09; 'unittest': 0.09; 'python': 0.11; 'jan': 0.12; "'__main__':": 0.16; 'editor,': 0.16; 'modules,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject: \n ': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'subject:project': 0.19; 'example': 0.22; 'import': 0.22; 'tests': 0.22; 'header:User- Agent:1': 0.23; 'certainly': 0.24; 'instance,': 0.24; 'skip:i 40': 0.24; 'skip:l 30': 0.24; 'paul': 0.24; 'file.': 0.24; '(or': 0.24; 'source': 0.25; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'fixed': 0.29; 'needed.': 0.30; 'work.': 0.31; 'skip:i 60': 0.31; 'file': 0.32; 'extend': 0.32; 'option': 0.32; 'run': 0.32; 'cases': 0.33; 'maybe': 0.34; 'subject:with': 0.35; 'skip:u 20': 0.35; 'test': 0.35; 'add': 0.35; 'idle': 0.36; "i'll": 0.36; 'changing': 0.37; 'unit': 0.37; 'too': 0.37; 'easily': 0.37; '8bit%:86': 0.38; 'depends': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'does': 0.39; 'functional': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'received:173': 0.61; 'between': 0.67; 'believe': 0.68; 'discover': 0.82; 'each,': 0.84; 'received:fios.verizon.net': 0.84; 'demand.': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Struggling with unittest discovery - how to structure my project test suite Date: Fri, 20 Dec 2013 16:48:28 -0500 References: <8607d86e-8fcf-41ac-8da2-a8c137afe087@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-173-75-254-207.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387576123 news.xs4all.nl 2952 [2001:888:2000:d::a6]:56726 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62455 On 12/20/2013 12:41 PM, Serhiy Storchaka wrote: > 20.12.13 16:47, Paul Moore =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=B2(=D0= =BB=D0=B0): >> What's the best way of structuring my projects so that: It depends on your tradeoff between extra setup in the files and how=20 much you type each time you run tests. >> 1. I can run all the tests easily on demand. I believe that if you copy Lib/idlelib/idle_test/__init__.py to=20 tests/__main__.py and add import unittest; unittest.main() then python -m tests would run all your tests. Lib/idlelib/idle_test/README.py may help explai= n. >> 2. I can run just the functional or unit tests when needed. > > python -m unittest discover -s tests/functional > python -m unittest discover tests/functional Ditto for __main__.py files in each, so python -m tests.unit (functional) will work. >> 3. I can run individual tests (or maybe just individual test modules, >> I don't have so many tests yet that I know how detailed I'll need to >> get!) without too much messing (and certainly without changing any >> source files!) > > python -m unittest discover -s tests/functional -p test_spam.py > python -m unittest discover tests/functional -p test_spam.py > python -m unittest discover tests/functional test_spam.py 'discover' is not needed for single files. For instance, python -m unittest idlelib.idle_test.test_calltips works for me. One can extend that to test cases and methods. python -m unittest idlelib.idle_test.test_calltips.Get_entityTest and python -m unittest=20 idlelib.idle_test.test_calltips.Get_entityTest.test_bad_entity If you add to each test_xyz.py file if __name__ =3D=3D '__main__': unittest.main(verbosity=3D2) # example of adding fixed option then python -m tests.unit.test_xyz will run the tests in that file. (So does F5 in an Idle editor, which is = how I run individual test files while editing. I copy the boilerplate=20 from README.txt or an existing test_xyz.py file.) --=20 Terry Jan Reedy