importing and nose

Discussion in 'Python' started by Andrea Crotti, Jan 19, 2012.

  1. 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?
     
    Andrea Crotti, Jan 19, 2012
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer
    Replies:
    3
    Views:
    416
    Chris Mahoney
    Jul 13, 2003
  2. plb
    Replies:
    2
    Views:
    364
  3. ANN: nose 0.9.0a1

    , May 1, 2006, in forum: Python
    Replies:
    0
    Views:
    318
  4. ANN: nose 0.9.0a1

    , May 1, 2006, in forum: Python
    Replies:
    0
    Views:
    322
  5. Replies:
    0
    Views:
    323
Loading...

Share This Page