1

I am developing a small project using Python 3.6 version. Implementing the unit test with unittest I have an error executing python3 -m unittest and I have not an error executing python -m unittest.

The error shows import error like:

ModuleNotFoundError: No module named 'genome'

Is there any import problem using unittest in Python 3.6?

1
  • Complete information about this error and the solution is post here. Commented Jun 2, 2017 at 9:01

3 Answers 3

1

You probably call two different versions of Python, that do not have the same packages installed.

It seems that genome is not installed with python3. If genome is an Internet installed package, you can fix this with

python3 -m pip install genome
Sign up to request clarification or add additional context in comments.

Comments

0

You can found the unittest module introduce document from https://docs.python.org/3/library/unittest.html

1 Comment

How this gonna solve the error mentionned previously?
0

It's difficult to answer without you showing your code, but to add to Guillaume's answer, the syntax for relative imports is different between python2 and python3

In python3, The only acceptable syntax for relative imports is from .[module] import name. All import forms not starting with . are interpreted as absolute imports.

See (PEP 0328) for more information

2 Comments

I read that links previously, and others, like saul comment. I do not understand the problem. As I posted yesterday here, from .module import * must work, but It does not work. I guess it's a subtle mistake.
So how are we supposed to link tests in a sister directory ( ../other )? I am working within a multi-language framework with the convention that each package has ONLY sub-directories, all predefined, and two of them being SRC/ and TEST/. The only option available for storing tests is (relative to source under test) ../TEST/test_[some_source]. Is there no way to make this work with unittest module?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.