Skip to content

Commit

Permalink
[fix] Fixed preventing non Django modules from using test utils
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Jul 9, 2024
1 parent 034816f commit 737ae94
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion openwisp_utils/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from unittest import TextTestResult, mock

from django.conf import settings
from django.contrib.auth.models import Permission
from django.db import DEFAULT_DB_ALIAS, connections
from django.test.runner import DiscoverRunner
from django.test.utils import CaptureQueriesContext
Expand Down Expand Up @@ -185,6 +184,10 @@ def _test_action_permission(
required_perms=None,
extra_payload=None,
):
# importing at the top breaks non-django python packages
# using some of the functions in this file (eg: netjsonconfig)
from django.contrib.auth.models import Permission

all_perms = {'add', 'change', 'delete', 'view'}
required_perms = required_perms or all_perms
extra_payload = extra_payload or {}
Expand Down

0 comments on commit 737ae94

Please sign in to comment.