Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78313
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Syntax error in python unittest script |
| Date | 2014-09-24 17:39 -0400 |
| References | <2c76f6c8-bb13-44e9-8da8-62a08e067b3a@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14333.1411594822.18130.python-list@python.org> (permalink) |
On 9/24/2014 3:33 PM, Milson Munakami wrote:
> I am learning to use unittest with python
[way too long example]
> File "TestTest.py", line 44
> def cleanup(self, success):
> ^
> SyntaxError: invalid syntax
A common recommendation is to find the *minimal* example that exhibits
the problem. (Start with commenting out everything after the code in
the traceback, then at least half the code before it. Etc.) That means
that removing or commenting out a single statememt and the problem
disappears. In compound statements, you may need to insert 'pass' to
not create a new problem.
If you had done that, you would have reduced your code to something like
class testFirewall( unittest.TestCase ):
def tearDown(self):
if self.reportStatus_:
self.log.info("=== Test %s completed normally (%d sec)", self.name_,
duration
def cleanup(self, success):
sys.excepthook = sys.__excepthook__
At that point, replacing "self.log.info(..." with "pass" would have made
it clear that the problem was with the replaced statement.
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Syntax error in python unittest script Milson Munakami <milsonmun@gmail.com> - 2014-09-24 12:33 -0700
Re: Syntax error in python unittest script Emile van Sebille <emile@fenx.com> - 2014-09-24 12:40 -0700
Re: Syntax error in python unittest script Peter Otten <__peter__@web.de> - 2014-09-24 21:41 +0200
Re: Syntax error in python unittest script Milson Munakami <milsonmun@gmail.com> - 2014-09-24 13:06 -0700
Re: Syntax error in python unittest script Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-09-24 21:28 +0100
Re: Syntax error in python unittest script Terry Reedy <tjreedy@udel.edu> - 2014-09-24 17:39 -0400
csiph-web