Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > importing and nose

Reply
Thread Tools

importing and nose

 
 
Andrea Crotti
Guest
Posts: n/a
 
      01-19-2012
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 "<string>", line 1, in <module>
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?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
nose, doctest, and module names in subpackages davidlmontgomery@gmail.com Python 0 09-06-2006 01:27 AM
Biting your nose to spite your face? Gordon Computer Support 1 02-24-2005 10:43 AM
How to keep a module with the same name as a module it is importing from importing itself? plb Python 2 02-08-2005 03:14 PM
Picking your nose and eating it is good for the immune system Tony Spadaro Digital Photography 11 06-22-2004 08:45 AM
Help: User control dim changes RIGHT UNDER MY NOSE! VB Programmer ASP .Net 3 07-13-2003 02:51 AM



Advertisments