Not appending ("lib") to sys.path breaks tests.
Leam Hall
leamhall at gmail.com
Fri Sep 8 17:54:56 EDT 2017
On 09/08/2017 05:41 PM, Ian Kelly wrote:
> I'm confused about where the character_tools import is made. If that's
> within a module in the lib package, it should be fine.
> It looks like it's failing to find the lib package. Since you removed
> the "lib" directory from sys.path, does its parent directory exist in
> sys.path?
The path is not in the modules path or in sys.path. Hence the append. I
thought I could add the local "lib" path via "." or "lib.", but it seems
not.
import lib.character fails in the tests/ directory.
>
> Relative imports are only allowed with the "from .foo import bar" syntax.
>
> However if you fix that, I suspect you're then going to run into the
> next error below here. I think you actually just want an absolute
> import like "import lib.character" here.
>
>
> Packages and directories are not the same thing. This is saying that
> the tests directory is not a package, so you can't do a relative
> import within it. You probably just want "from lib.character_tools
> import *".
>
> The Python 3 errors are the same as the above.
>
More information about the Python-list
mailing list