Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'suppose': 0.05; 'exec': 0.07; 'nameerror:': 0.09; 'def': 0.13; 'clue?': 0.16; 'setup(self):': 0.16; 'trying': 0.20; "doesn't": 0.22; 'tests.': 0.23; 'defined': 0.24; 'code': 0.25; 'import': 0.27; "i'm": 0.27; 'script': 0.28; 'skip:p 30': 0.29; 'class': 0.29; 'cmd': 0.30; 'fails,': 0.30; 'actually': 0.32; 'message-id:@gmail.com': 0.33; 'header:User-Agent:1': 0.33; 'to:addr:python-list': 0.33; 'received:209.85.212': 0.34; 'running': 0.35; 'test': 0.35; 'file': 0.35; 'but': 0.37; 'received:google.com': 0.37; 'another': 0.37; 'some': 0.38; 'received:209.85': 0.38; 'sense': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'locals': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=7w06RM6VItWxAoIsPNksSLBTHZzZps3owtbR91K4Fm4=; b=NefVYrrVdqG32hrriynfgwNjz8HpehSaa1JNx3Qa3Q5L6pUPncIcbHpvvpWHgNwOC4 DFB8fD0tvzH+I4YBRDStF8oLBdT2EeVgJ1Cu6Sg8+oDDhEhRGlhPWToQB9g+SpB+LDT2 4vDR+f7dYC2oHMQZ24/ONtpcDJU/2T2pugg1Y= Date: Thu, 19 Jan 2012 17:11:11 +0000 From: Andrea Crotti User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111224 Thunderbird/9.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: importing and nose Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326993075 news.xs4all.nl 6908 [2001:888:2000:d::a6]:47218 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19132 I'm writing some code to analyse pstats statistics, and I'm trying to have some working unit tests. Suppose I have in the test directory another directory 'profiling', which contains 'x.py', and 'b.py'. Now running the following code in a script works perfectly, class TestStatParser(unittest.TestCase): def setUp(self): self.temp_file = tempfile.mktemp() prof_path = path.join(path.dirname(__file__), 'profiling') sys.path.append(prof_path) import x profile.run('x.f1()', filename=self.temp_file) But running it within nose I get the following exec cmd in globals, locals File "", line 1, in NameError: name 'x' is not defined Which doesn't make sense to me, because the import doesn't actually fails, so how can x not be defined??? Any clue?