[BUG] Evennia test raises RuntimeError after upgrade to django 3.2
See original GitHub issueDescribe the bug
I decided to finally see about maybe updating the version of Evennia I’m using for Arx. There were a few trivial changes to address deprecations, but a more serious issue is that the test runner completely refuses to function. After running through migrations for the test database and adding context types/permissions, I get the following error, which only touches library code:
Using settings file 'test_settings' (server.conf.test_settings).
TESTING: Using specified settings file 'server.conf.test_settings'.
OBS: Evennia's full test suite may not pass if the settings are very
different from the default (use 'evennia test evennia' to run core tests)
Creating test database for alias 'default'...
Traceback (most recent call last):
File "D:\arx\venv\Scripts\evennia_launcher.py", line 18, in <module>
main()
File "D:\arx\evennia\evennia\server\evennia_launcher.py", line 2282, in main
sys.exit(execute_from_command_line(sys.argv))
File "D:\arx\venv\Lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "D:\arx\venv\Lib\site-packages\django\core\management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\arx\venv\Lib\site-packages\django\core\management\commands\test.py", line 23, in run_from_argv
super().run_from_argv(argv)
File "D:\arx\venv\Lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\arx\venv\Lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "D:\arx\venv\Lib\site-packages\test_without_migrations\management\commands\_base.py", line 78, in handle
super(CommandMixin, self).handle(*test_labels, **options)
File "D:\arx\venv\Lib\site-packages\django\core\management\commands\test.py", line 55, in handle
failures = test_runner.run_tests(test_labels)
File "D:\arx\venv\Lib\site-packages\django\test\runner.py", line 725, in run_tests
old_config = self.setup_databases(aliases=databases)
File "D:\arx\venv\Lib\site-packages\django\test\runner.py", line 643, in setup_databases
return _setup_databases(
File "D:\arx\venv\Lib\site-packages\django\test\utils.py", line 179, in setup_databases
connection.creation.create_test_db(
File "D:\arx\venv\Lib\site-packages\django\db\backends\base\creation.py", line 90, in create_test_db
self.connection._test_serialized_contents = self.serialize_db_to_string()
File "D:\arx\venv\Lib\site-packages\django\db\backends\base\creation.py", line 136, in serialize_db_to_string
serializers.serialize("json", get_objects(), indent=None, stream=out)
File "D:\arx\venv\Lib\site-packages\django\core\serializers\__init__.py", line 129, in serialize
s.serialize(queryset, **options)
File "D:\arx\venv\Lib\site-packages\django\core\serializers\base.py", line 90, in serialize
for count, obj in enumerate(queryset, start=1):
File "D:\arx\venv\Lib\site-packages\django\db\backends\base\creation.py", line 125, in get_objects
for model in app_config.get_models():
File "D:\arx\venv\Lib\site-packages\django\apps\config.py", line 287, in get_models
for model in self.models.values():
RuntimeError: dictionary changed size during iteration
To Reproduce
Steps to reproduce the behavior:
- Have a game with other apps/models
- run
evennia test --settings=<your settings file here>
- See error
Expected behavior
The test runner to function the same as it did in django 2.12
Environment, Evennia version, OS etc
Evennia 0.9.5 (rev 8f916cb20) (rev 8f916cb20) OS: nt Python: 3.8.3 Twisted: 21.7.0 Django: 3.2.16
Additional context
My only running theory is that it might have something to do with how Evennia creates typeclasses, since they’re proxy models that aren’t fully registered. If you try to run makemigrations
it’ll try to generate bogus migrations inside the evennia.typeclasses app. Possibly they could be mucking up the test database here in some way with some new change they made in django’s test runner in 3.2?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
Closing this; we won’t accept any more changes to master branch, nor for Django 3.2.x.
Yes, we need to run app-specific
makemigrations
when adding custom tables exactly to avoid this. The Typeclass system is basically a hack on top of Django to extend the functionality of Proxy models and be able to treat them as quasi ‘real’ models for the purpose of searching and letting people not having to learn Django to make their own subclasses (with meta boilerplate etc). The drawback is that it fools Django migrations into thinking they should be considered.Interesting that Django 4.x works for you, but not 3.2.x. I’ve not heard any other issues with that. Alas, Evennia 0.9.5 does not run on 4.x at this point so moving to
develop
or wait for 1.0 release would be the options in that case.We can keep this open for now, in case someone else runs into it, but I don’t expect to be spending any time investigating this for master branch, so this sounds like it will not be addressed (at least not by me).