Skip to content

Commit bf83e04

Browse files
authored
[Fixies #13057] Removing Twisted library from the dependencies and the related code (#13058)
* removing Twisted library from the dependencies and the related code * black reformatting
1 parent a2da1b4 commit bf83e04

File tree

5 files changed

+1
-96
lines changed

5 files changed

+1
-96
lines changed

geonode/tests/suite/base.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from twisted.python import log
2-
31
from django.conf import settings
42
from django.core import management
53
from django.core.management import call_command
@@ -39,30 +37,3 @@ def destroy_test_db(database_name):
3937

4038
def load_db_fixtures(fixtures):
4139
call_command("loaddata", *fixtures)
42-
43-
44-
def setup_test_db(worker_index, fixtures, fn, *args):
45-
management.get_commands()
46-
management._commands["syncdb"] = "django.core"
47-
48-
old_name = settings.DATABASES["default"]["NAME"]
49-
if worker_index is not None:
50-
test_database_name = f"test_{worker_index}_{old_name}"
51-
else:
52-
test_database_name = f"test_{old_name}"
53-
54-
create_test_db(test_database_name)
55-
if fixtures:
56-
load_db_fixtures(fixtures)
57-
58-
result = None
59-
try:
60-
result = fn(*args)
61-
except Exception as e:
62-
log.err(str(e))
63-
raise
64-
finally:
65-
destroy_test_db(test_database_name)
66-
67-
connection.settings_dict["NAME"] = old_name
68-
return result

geonode/tests/suite/runner.py

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@
1111
from queue import Empty
1212
from typing import Collection
1313

14-
from twisted.scripts.trial import Options, _getSuite
15-
from twisted.trial.runner import TrialRunner
16-
1714
from django.conf import settings
1815

1916
from django.test.runner import DiscoverRunner
2017
from django.db import connections, DEFAULT_DB_ALIAS
2118
from django.core.exceptions import ImproperlyConfigured
2219

23-
from .base import setup_test_db
2420

2521
# "auto" - one worker per Django application
2622
# "cpu" - one worker per process core
@@ -286,12 +282,7 @@ def pop_item():
286282
results_queue.put((group, result))
287283
logger.debug(f"Worker {index} has finished running tests {tests}")
288284
except (KeyboardInterrupt, SystemExit):
289-
if isinstance(self, TwistedParallelTestSuiteRunner):
290-
# Twisted raises KeyboardInterrupt when the tests
291-
# have completed
292-
pass
293-
else:
294-
raise
285+
raise
295286
except Exception as e:
296287
logger.debug(f"Running tests failed, reason: {e}")
297288
result = TestResult().from_exception(e)
@@ -517,60 +508,6 @@ def __init__(self, verbosity=2, failfast=True, **kwargs):
517508
super().__init__(stream=stream, verbosity=verbosity, failfast=failfast)
518509

519510

520-
class TwistedParallelTestSuiteRunner(ParallelTestSuiteRunner):
521-
def __init__(self, config, verbosity=1, interactive=False, failfast=True, **kwargs):
522-
self.config = config
523-
super().__init__(verbosity, interactive, failfast, **kwargs)
524-
525-
def run_tests(self, test_labels, extra_tests=None, **kwargs):
526-
app_tests = self._group_by_app(test_labels)
527-
return self._run_tests(tests=app_tests)
528-
529-
def run_suite(self):
530-
# config = self.config
531-
tests = self.config.opts["tests"]
532-
533-
tests = self._group_by_file(tests)
534-
self._run_tests(tests=tests)
535-
536-
def _tests_func(self, tests, worker_index):
537-
if not isinstance(tests, (list, set)):
538-
tests = [tests]
539-
540-
args = ["-e"]
541-
args.extend(tests)
542-
543-
config = Options()
544-
config.parseOptions(args)
545-
546-
stream = BufferWritesDevice()
547-
runner = self._make_runner(config=config, stream=stream)
548-
suite = _getSuite(config)
549-
result = setup_test_db(worker_index, None, runner.run, suite)
550-
result = TestResult().from_trial_result(result)
551-
return result
552-
553-
def _make_runner(self, config, stream):
554-
# Based on twisted.scripts.trial._makeRunner
555-
mode = None
556-
if config["debug"]:
557-
mode = TrialRunner.DEBUG
558-
if config["dry-run"]:
559-
mode = TrialRunner.DRY_RUN
560-
return TrialRunner(
561-
config["reporter"],
562-
mode=mode,
563-
stream=stream,
564-
profile=config["profile"],
565-
logfile=config["logfile"],
566-
tracebackFormat=config["tbformat"],
567-
realTimeErrors=config["rterrors"],
568-
uncleanWarnings=config["unclean-warnings"],
569-
workingDirectory=config["temp-directory"],
570-
forceGarbageCollection=config["force-gc"],
571-
)
572-
573-
574511
class TestResult:
575512
dots = False
576513
errors = None

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ pytest-splinter==3.3.2
161161
pytest-django==4.8.0
162162
pip==25.0.1
163163
setuptools>=70.2.0,<70.3.0
164-
Twisted==24.3.0
165164
pixelmatch==0.3.0
166165
factory-boy==3.3.0
167166
flaky==3.8.1

requirements_tests.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
Twisted
21
pixelmatch==0.3.0
32
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ install_requires =
183183
pytest-django==4.8.0
184184
pip==24.1.2
185185
setuptools>=70.2.0,<70.3.0
186-
Twisted==24.3.0
187186
pixelmatch==0.3.0
188187
factory-boy==3.3.0
189188
flaky==3.8.1

0 commit comments

Comments
 (0)