importing and nose

A

Andrea Crotti

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top