Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78313

Re: Syntax error in python unittest script

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'subject:error': 0.03; 'syntax': 0.04; 'insert': 0.05; '(%d': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:script': 0.09; 'unittest': 0.09; 'python': 0.11; 'def': 0.12; 'jan': 0.12; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'statement.': 0.16; 'statements,': 0.16; 'syntaxerror:': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'replacing': 0.19; 'example': 0.22; 'header:User-Agent:1': 0.23; 'least': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'code': 0.31; 'reduced': 0.31; 'file': 0.32; 'class': 0.32; 'problem': 0.35; 'common': 0.35; 'problem.': 0.35; 'something': 0.35; 'etc.)': 0.35; 'test': 0.35; 'done': 0.36; 'half': 0.37; 'too': 0.37; 'clear': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'duration': 0.60; 'removing': 0.60; 'completed': 0.61; 'new': 0.61; 'invalid': 0.68; 'commenting': 0.84; 'received:fios.verizon.net': 0.84; 'received:108': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: Syntax error in python unittest script
Date Wed, 24 Sep 2014 17:39:38 -0400
References <2c76f6c8-bb13-44e9-8da8-62a08e067b3a@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-108-16-203-145.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
In-Reply-To <2c76f6c8-bb13-44e9-8da8-62a08e067b3a@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14333.1411594822.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1411594822 news.xs4all.nl 2882 [2001:888:2000:d::a6]:44982
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:78313

Show key headers only | View raw


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


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