c646392b84
- Preserve snake customizations across database migrations and merges. - Lazily load optional storage backends for SQLite maintenance scripts. - Match Apex territory and nearest-food tie-breaking semantics. - Resolve duel occupancy after simultaneous movement and food growth. - Recompute simulated head-to-head danger after body growth. - Add regression coverage and declare the aiofiles dependency.
33 lines
968 B
Python
33 lines
968 B
Python
import subprocess
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
class TestDatabasePackageImports(unittest.TestCase):
|
|
def test_sqlite_backend_import_does_not_require_aiofiles(self):
|
|
project_root = Path(__file__).resolve().parents[1]
|
|
script = """
|
|
import builtins
|
|
|
|
original_import = builtins.__import__
|
|
def reject_aiofiles(name, *args, **kwargs):
|
|
if name == 'aiofiles' or name.startswith('aiofiles.'):
|
|
raise ModuleNotFoundError("aiofiles intentionally unavailable")
|
|
return original_import(name, *args, **kwargs)
|
|
|
|
builtins.__import__ = reject_aiofiles
|
|
from server.database.backend.SqliteGameplayBackend import SqliteGameplayBackend
|
|
assert SqliteGameplayBackend.__name__ == 'SqliteGameplayBackend'
|
|
"""
|
|
result = subprocess.run(
|
|
[sys.executable, "-c", script],
|
|
cwd=project_root,
|
|
text=True,
|
|
capture_output=True,
|
|
)
|
|
|
|
self.assertEqual(result.returncode, 0, result.stderr)
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|