First time here? Check out the FAQ!

Revision history  [back]

using relative import in a test file

I have a tests module which ends with if_name_ = '__main--' : import unittest unittest.main().

I would like to be able to use relative imports in the module. if I used a launch configuration I get a no parent package error, which is confirmed by a print at the top of the module where package is None. My understanding is that therefore I should launch it as a module with python -m When I select this option and add the name of the module as a run argument in the form of parent_package.module wing refuses to laucnh the module sayin it needs a dotted name.

Do you have a hint to launch this module as a main. I thank you in advance.

PS. I have a __init__.py in the same directory as my test module. and the parent.parent.parent directory is in the python Path

using relative import in a test file

I have a tests module which ends with if_name_ = '__main--' : import unittest unittest.main().

I would like to be able to use relative imports in the module. if I used a launch configuration I get a no parent package error, which is confirmed by a print at the top of the module where package is None. My understanding is that therefore I should launch it as a module with python -m When I select this option and add the name of the module as a run argument in the form of parent_package.module wing refuses to laucnh the module sayin it needs a dotted name.

Do you have a hint to launch this module as a main. I thank you in advance.

PS. I have a __init__.py in the same directory as my test module. and the parent.parent.parent directory is in the python Path

using relative import in a test file

I have a tests module which ends with if_name_ = '__main--' : import unittest unittest.main().

I would like to be able to use relative imports in the module. if I used a launch configuration I get a no parent package error, which is confirmed by a print at the top of the module where package is None. My understanding is that therefore I should launch it as a module with python -m When I select this option and add the name of the module as a run argument in the form of parent_package.module wing refuses to laucnh the module sayin it needs a dotted name.

Do you have a hint to launch this module as a main. I thank you in advance.

PS. I have a __init__.py in the same directory as my test module. and the parent.parent.parent directory is in the python Path