Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'scripts': 0.03; 'subject: -- ': 0.07; 'arguments,': 0.09; 'executable': 0.09; 'parsing': 0.09; 'run,': 0.09; 'subject:command': 0.09; 'subset': 0.09; 'cc:addr:python-list': 0.11; '-tkc': 0.16; 'command-line': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'scripts.': 0.16; 'subject: \n ': 0.16; 'subject:projects': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'tests': 0.22; 'cc:addr:python.org': 0.22; 'config': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; 'script': 0.25; 'subject:/': 0.26; 'header:In-Reply- To:1': 0.27; 'points': 0.29; 'usually': 0.31; 'up:': 0.31; 'subject:the': 0.34; 'subject:from': 0.34; 'something': 0.35; 'usual': 0.35; 'test': 0.35; 'done': 0.36; 'entry': 0.36; 'two': 0.37; 'easily': 0.37; 'depends': 0.38; 'tools,': 0.38; 'skip:[ 10': 0.38; 'skip:- 10': 0.38; 'does': 0.39; 'even': 0.60; 'behavior': 0.77; 'harness': 0.84; 'received:50.22': 0.84; 'subject:Testing': 0.84 Date: Thu, 31 Oct 2013 19:45:18 -0500 From: Tim Chase To: =?UTF-8?B?R8O2a3R1xJ8=?= Kayaalp Subject: Re: Testing python command line apps -- Running from within the projects w/o installing In-Reply-To: <20131031201207.GA9547@proxima.centauri> References: <20131031201207.GA9547@proxima.centauri> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com Cc: python-list@python.org 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1383266628 news.xs4all.nl 15960 [2001:888:2000:d::a6]:44406 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58219 On 2013-10-31 22:12, G=C3=B6ktu=C4=9F Kayaalp wrote: > My usual practise is to have two entry points to the program as > executable scripts.=20 When I create stand-alone command-line scripts that take arguments, usually they're akin to version-control tools, so I have the form scriptname.py [--global-opts] [--command-opts] [args] so I just make one of my s allow for "test". That way, I can execute my tests as easily as my program. If I've added config parsing and script behavior depends on them, I might even create a test harness that does something like #!/bin/sh for f in one.ini two.ini three.ini do scriptname.py --config=3D"$f" test done That way, if some of my tests take a long time to run, I can even make sub-commands to test a subset of the functionality to speed it up: scriptname.py test web-ui scriptname.py test database ... -tkc