Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #89811
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!newsfeed.pionier.net.pl!feed.xsnews.nl!border03.ams.xsnews.nl!feeder03.ams.xsnews.nl!abp002.ams.xsnews.nl!frontend-F10-05.ams.news.kpn.nl |
|---|---|
| From | Cecil Westerhof <Cecil@decebal.nl> |
| Newsgroups | comp.lang.python |
| Subject | Is this a good way to implement testing |
| Organization | Decebal Computing |
| X-Face | "(y8cC@tg_12{">GF'UXTW]FHI2wMiZNrnf'1EFQ&O#$m:f#O7+7}kR<J%a^F2lh4[N~Yz4 nSp#c+aQo1b5=?HcNEkQ7QzF<])O3X4MDL/AYjys&*mt>,v+Pti8=Vi/Z"g^?b"E |
| X-Homepage | http://www.decebal.nl/ |
| Date | Sun, 03 May 2015 00:29:17 +0200 |
| Message-ID | <878ud6mx4y.fsf@Equus.decebal.nl> (permalink) |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
| Cancel-Lock | sha1:t9HWlpeYyl+pdyMBV7fNAD7eze4= |
| MIME-Version | 1.0 |
| Content-Type | text/plain |
| Lines | 60 |
| NNTP-Posting-Host | 81.207.62.244 |
| X-Trace | 1430606689 news.kpn.nl 21109 81.207.62.244@kpn/81.207.62.244:51592 |
| Xref | csiph.com comp.lang.python:89811 |
Show key headers only | View raw
Still on my journey to learn Python.
At the moment I define the test functionality in the following way:
if __name__ == '__main__':
keywords = [
'all',
'factorial',
'fibonacci',
'happy',
'lucky',
]
keywords_msg = [
'--all',
'--factorial',
'--fibonacci',
'--happy',
'--lucky',
]
(options,
extraParams) = getopt.getopt(sys.argv[1:], '', keywords)
progname = split(sys.argv[0])[1]
if len(options) > 1 or len(extraParams) != 0:
error = '{0}: Wrong parameters ({1})'. \
format(progname, ' '.join(sys.argv[1:]))
usage = ' {0} {1}'.format(progname, ' | '.join(keywords_msg))
print(error, file = sys.stderr)
print(usage, file = sys.stderr)
sys.exit(1)
do_all = do_factorial = do_fibonacci = do_happy = do_lucky = False
if len(options) == 0:
do_all = True
else:
action = options[0][0]
if action == '--all':
do_all = True
elif action == '--factorial':
do_factorial = True
elif action == '--fibonacci':
do_fibonacci = True
elif action == '--happy':
do_happy = True
elif action == '--lucky':
do_lucky = True
else:
print >> sys.stderr, progname + ': Unhandled parameter ' + action
sys.exit(1)
if do_all or do_factorial:
.
.
.
Is this an acceptable way of working?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Is this a good way to implement testing Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 00:29 +0200
Re: Is this a good way to implement testing Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-03 00:17 +0100
Re: Is this a good way to implement testing Terry Reedy <tjreedy@udel.edu> - 2015-05-02 20:06 -0400
Re: Is this a good way to implement testing Paul Rubin <no.email@nospam.invalid> - 2015-05-02 20:58 -0700
Re: Is this a good way to implement testing Ben Finney <ben+python@benfinney.id.au> - 2015-05-03 14:49 +1000
Re: Is this a good way to implement testing Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 09:36 +0200
Re: Is this a good way to implement testing Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-03 09:38 +0100
Re: Is this a good way to implement testing Peter Otten <__peter__@web.de> - 2015-05-03 10:45 +0200
Re: Is this a good way to implement testing Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 11:49 +0200
Re: Is this a good way to implement testing Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-03 11:21 +0100
Re: Is this a good way to implement testing Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 12:50 +0200
Re: Is this a good way to implement testing Ben Finney <ben+python@benfinney.id.au> - 2015-05-03 18:52 +1000
Re: Is this a good way to implement testing Peter Otten <__peter__@web.de> - 2015-05-03 11:22 +0200
csiph-web