| 
									
										
										
										
											2023-10-31 02:08:56 +01:00
										 |  |  | import unittest | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from worlds.AutoWorld import AutoWorldRegister | 
					
						
							|  |  |  | from . import setup_solo_multiworld | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class TestWorldMemory(unittest.TestCase): | 
					
						
							| 
									
										
										
										
											2025-01-17 11:14:21 -08:00
										 |  |  |     def test_leak(self) -> None: | 
					
						
							| 
									
										
										
										
											2023-10-31 02:08:56 +01:00
										 |  |  |         """Tests that worlds don't leak references to MultiWorld or themselves with default options.""" | 
					
						
							|  |  |  |         import gc | 
					
						
							|  |  |  |         import weakref | 
					
						
							|  |  |  |         for game_name, world_type in AutoWorldRegister.world_types.items(): | 
					
						
							|  |  |  |             with self.subTest("Game", game_name=game_name): | 
					
						
							|  |  |  |                 weak = weakref.ref(setup_solo_multiworld(world_type)) | 
					
						
							|  |  |  |                 gc.collect() | 
					
						
							|  |  |  |                 self.assertFalse(weak(), "World leaked a reference") |