File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -3,3 +3,4 @@ addopts = -p no:warnings --create-db --reuse-db --nomigrations
33DJANGO_SETTINGS_MODULE = openwisp2.settings
44python_files = pytest*.py
55python_classes = *Test*
6+ pythonpath = tests
Original file line number Diff line number Diff line change 55import subprocess
66import sys
77
8- import pytest
9-
108
119def run_tests (args , settings_module ):
1210 """
@@ -20,6 +18,9 @@ def run_tests(args, settings_module):
2018
2119
2220if __name__ == '__main__' :
21+ # Configure Django settings for test execution
22+ # (sets Celery to eager mode, configures in-memory channels layer, etc.)
23+ os .environ .setdefault ('TESTING' , '1' )
2324 base_args = sys .argv .copy ()[1 :]
2425 if not os .environ .get ('SAMPLE_APP' , False ):
2526 test_app = 'openwisp_controller'
@@ -43,5 +44,8 @@ def run_tests(args, settings_module):
4344 run_tests (psql_args , 'openwisp2.postgresql_settings' )
4445
4546 # Run pytest tests
46- sys .path .insert (0 , 'tests' )
47- sys .exit (pytest .main ([app_dir ]))
47+ result = subprocess .run (
48+ ['pytest' , app_dir ],
49+ )
50+ if result .returncode != 0 :
51+ sys .exit (result .returncode ) # Exit immediately if tests fail
Original file line number Diff line number Diff line change 33
44BASE_DIR = os .path .dirname (os .path .abspath (__file__ ))
55DEBUG = True
6- TESTING = sys .argv [1 :2 ] == ['test' ]
6+ TESTING = os . environ . get ( 'TESTING' , False ) or sys .argv [1 :2 ] == ['test' ]
77SELENIUM_HEADLESS = True if os .environ .get ('SELENIUM_HEADLESS' , False ) else False
88SHELL = 'shell' in sys .argv or 'shell_plus' in sys .argv
99REDIS_URL = os .getenv ('REDIS_URL' , 'redis://localhost:6379' )
You can’t perform that action at this time.
0 commit comments