jeudi 17 janvier 2019

How to avoid circular import within django's tests dir?

I'm trying to fix a circular import issue I'm having with Django tests.

My dir structure is:

app/tests:
  test_user_level01.py
  test_user_level02.py

Within each file I have classes to test get 200s and get 403s (among other classes). Users in level 2 should have all the get 200s that level 1 users have and users in level 1 should have all the get 403s that the level 2 users have. Thus I have a circular import.

Normally I would solve this with an absolute import but I can't figure out what that would be.

I've tried:

"""test_user_level01.py"""
from . import test_user_level02


"""test_user_level02.py"""
from . import test_user_level01

But this seems to give a circular import error (missing classes).

Thank you ahead of time for your help.

PS. The following doesn't work:

import app.tests.test_user_level01

OR:

import .test_user_level01

Aucun commentaire:

Enregistrer un commentaire