close

[Solved] Attribute: ‘module’ object has no attribute ‘tests’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Attribute: ‘module’ object has no attribute ‘tests’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Attribute: ‘module’ object has no attribute ‘tests’ Error Occurs?

Today I get the following error Attribute: ‘module’ object has no attribute ‘tests’ in python.

How To Solve Attribute: ‘module’ object has no attribute ‘tests’ Error ?

  1. How To Solve Attribute: 'module' object has no attribute 'tests' Error ?

    To Solve Attribute: 'module' object has no attribute 'tests' Error I finally figured it out working on another problem. The problem was that my test couldn't find an import.

  2. Attribute: 'module' object has no attribute 'tests'

    To Solve Attribute: 'module' object has no attribute 'tests' Error I finally figured it out working on another problem. The problem was that my test couldn't find an import.

Solution 1

I finally figured it out working on another problem. The problem was that my test couldn’t find an import.

It looks like you get the above error if your test fails to import. This makes sense because the test suite can’t import a broken test. At least I think this is what is going on because I fixed the import within my test file and sure enough it started working.

To validate your test case just try import the test case file in python console.

Example:

from project.apps.app1.tests import *

Solution 2

Use:

./manage.py shell

followed by

import myapp.tests

to find the nature of the import error.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read