Something went wrong. Try again.
Native control, inspection, UI automation and evidence capture for a running Witcher 3 process.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435from pathlib import Pathimport tempfileimport unittestfrom unittest.mock import patchfrom witcher_devkit import background as b
class BackgroundTests(unittest.TestCase): def test_preset_and_restore_preserve_unrelated_bytes(self): raw=b'[Other]\r\nResolution=leave\r\n[Viewport]\r\nResolution="2560x1440"\r\nFullScreenMode=2\r\nVSync=false\r\n[Game]\r\nDoNotPauseWhileStopped=false\r\n' previous=b.viewport(raw);after=b.viewport(raw,b.PRESET) self.assertEqual(b.viewport(after),b.PRESET) self.assertIn(b'[Other]\r\nResolution=leave',after) self.assertIn(b'DoNotPauseWhileStopped=false',after) self.assertEqual(b.viewport(after,previous),raw)
def test_missing_or_duplicate_display_key_rejected(self): for raw in [b'[Other]\nResolution=x\n',b'[Viewport]\nResolution=x\n',b'[Viewport]\nResolution=x\nResolution=y\nFullScreenMode=2\n']: with self.assertRaises(ValueError):b.viewport(raw)
def test_unowned_library_is_not_adopted(self): with tempfile.TemporaryDirectory() as tmp: root=Path(tmp);target=root/'plugin';target.write_bytes(b'not ours') with patch.object(b,'TARGET',target),patch.object(b,'RECEIPT',root/'receipt'): with self.assertRaisesRegex(RuntimeError,'without an ownership receipt'):b.verify()
def test_disable_refuses_external_display_change(self): with tempfile.TemporaryDirectory() as tmp: root=Path(tmp);settings=root/'settings';settings.write_bytes(b'[Viewport]\nResolution="800x600"\nFullScreenMode=0\n') receipt=root/'receipt';receipt.write_text('{"preset":{"Resolution":"\\\"1920x1080\\\"","FullScreenMode":"0"}}') with patch.object(b,'SETTINGS',settings),patch.object(b,'RECEIPT',receipt),patch.object(b,'verify',return_value=True),patch.object(b.support.manage,'ensure_game_closed'): with self.assertRaisesRegex(RuntimeError,'changed externally'):b.disable() self.assertIn(b'800x600',settings.read_bytes())
if __name__=='__main__':unittest.main()