def test_del_key(self): key = RegistryKey(self.SET_TEST_KEY_PATH) if not key.is_key(): key.create() key.flush() key.delete() assert not key.is_key()
def test_create(self): key = RegistryKey(self.SET_TEST_KEY_PATH) if key.is_key(): key.delete() key.create() assert key.is_key() key.delete()
def test_get_fail(self): key = RegistryKey(self.SET_TEST_KEY_PATH) if not key.is_key(): key.create() with pytest.raises(KeyError): key['InvalidKey'] key.delete()
def test_subkeys(self): key = RegistryKey(r'HKEY_CURRENT_USER\harmless_key') if not key.is_key(): key.create() (key / 'test1').create() (key / 'test2').create() assert len(key.subkeys()) == 2 key.delete()
def test_copy(self): key = RegistryKey(r'HKCU\harmless_key') if not key.is_key(): key.create() key['valuetest'] = Dword(7) (key / 'test1').create() (key / 'test1')['valuetest'] = Dword(42) new_key = key.parent / 'harmless2' key.copy(new_key) assert new_key['valuetest'] == 7 assert (new_key / 'test1')['valuetest'] == 42 key.delete() new_key.delete()
def test_walk(self): key = RegistryKey(r'HKCU\harmless_key') if not key.is_key(): key.create() (key / 'test1').create() (key / 'test1/test11').create() (key / 'test1/test12').create() (key / 'test2').create() (key / 'test2/test21').create() walk_results = list(key.walk()) expected_results = [ (key, ['test1', 'test2']), (key / 'test1', ['test11', 'test12']), (key / 'test2', ['test21']), ] for actual, expected in zip(walk_results, expected_results): assert actual == expected key.delete()