cannot import name models

19 views
Skip to first unread message

graf...@gmail.com

unread,
May 23, 2018, 2:08:30 PM5/23/18
to Factory Boy
Hello everyone,

I am attempting to create a very basic model for testing purposes and i'm unable to import the base requirements for factory boy at all.

I am stuck at this part:
```
import factory
from . import models
```

I ran pip install factory_boy


No matter what I do I see this error:

Error
Traceback (most recent call last):
File "/Users/agraff/anaconda/envs/py3/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/Users/agraff/anaconda/envs/py3/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/Users/agraff/anaconda/envs/py3/lib/python3.6/unittest/loader.py", line 34, in testFailure
raise self._exception
ImportError: Failed to import test module: test_core_datalake_client
Traceback (most recent call last):
File "/Users/agraff/anaconda/envs/py3/lib/python3.6/unittest/loader.py", line 153, in loadTestsFromName
module = __import__(module_name)
File "/Users/agraff/sl-datalake-api/tests/test_core_datalake_client.py", line 5, in <module>
from tests.factories.event import EventFactory
File "/Users/agraff/sl-datalake-api/tests/factories/event.py", line 2, in <module>
from . import models
ImportError: cannot import name 'models'


Normally I wouldn't bother everyone here but I don't see this anywhere online :(

Raphaël Barrois

unread,
May 23, 2018, 3:54:05 PM5/23/18
to graf...@gmail.com, Factory Boy
Hi,

The error message indicates that there is no "models.py" in /Users/agraff/sl-datalake-api/tests/factories/ ; you should
use a valid import path to your actual models instance (maybe ``..models`` if the file is
in /Users/agraff/sl-datalake-api/, or something else depending on your project layout.

--
Raphaël

Reply all
Reply to author
Forward
0 new messages