1

I have the following directory structure:

Master -------Tests |-----------test_extract.py -------Scripts |-----------extract.py 

This I'm trying to do a unit test file for extract.py. However, I'm receiving the following error:

"not {}".format(type(path)))

RuntimeError: 'path' must be None or a list, not >'_frozen_importlib_external._NamespacePath'>

This is how I'm trying to import the extract module:

import unittest import sys print (sys.path[0]) sys.path.insert(0, sys.path[0]+'\\Scripts') from Scripts import extract 

I'm using Python 3.5. Please advice.

Thanks

1
  • Why do you do it sys.path.insert(0, sys.path[0]+'\\Scripts')? Did you try just import packege to test module? Commented Oct 4, 2017 at 18:49

1 Answer 1

2

This should work for you:

import sys, os myPath = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, myPath + '/../') from Scripts import extract 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.