unittest import error

Curyous
2006-11-29
2013-03-15
  • Curyous
    Curyous
    2006-11-29

    I have a package 'UnitTests', containing the following file TestWork.py:

    import unittest

    #import StartUp

    class TestWork(unittest.TestCase):

        def testOne(self):
           
            self.assertEqual(True, False)
       

    if __name__ == '__main__':
        unittest.main()

    The folder also contains __init__.py:
    __all__ = [TestWork]

    If I run it, the unit test works OK, but if I uncomment 'import StartUp' which is a module in the root folder (one down from UnitTests), there is an error when importing TestWork.

    How do I rectify this?  I would appreciate suggestions, I'm sure it's something simple that I'm missing.

     
    • Curyous
      Curyous
      2006-11-30

      I managed to solve this by going to Project -> Properties, and adding all source folders to PYTHONPATH.

       
      • Fabio Zadrozny
        Fabio Zadrozny
        2006-11-30

        Yeap, that's the right way for doing it.

        You should take a look at the getting started manual: http://fabioz.com/pydev/manual_101_root.html it covers topics on how to configure your project (among others).

        Cheers,

        Fabio