conftest.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """
  2. All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. its licensors.
  4. For complete copyright and license terms please see the LICENSE at the root of this
  5. distribution (the "License"). All use of this software is governed by the License,
  6. or, if provided, by the license below or the license accompanying this file. Do not
  7. remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. """
  10. import logging
  11. import pytest
  12. import winreg
  13. import automatedtesting_shared.registry_utils as reg
  14. logger = logging.getLogger(__name__)
  15. layout = {
  16. 'path': r'Software\Amazon\Lumberyard\Editor\fancyWindowLayouts',
  17. 'value': 'last'
  18. }
  19. restore_camera = {
  20. 'new': 16384,
  21. 'path': r'Software\Amazon\Lumberyard\Editor\AutoHide',
  22. 'value': 'ViewportCameraRestoreOnExitGameMode'
  23. }
  24. @pytest.fixture(autouse=True)
  25. def set_editor_registry_defaults(request):
  26. # Records editor settings at start, sets to default, then returns to original at teardown.
  27. logger.debug('Executing an Editor settings fixture. If not executing an Editor test, this may be in error.')
  28. layout['original'] = reg.get_ly_registry_value(layout['path'], layout['value'])
  29. restore_camera['original'] = reg.get_ly_registry_value(restore_camera['path'], restore_camera['value'])
  30. # Deleting current layout value to restore defaults
  31. reg.delete_ly_registry_value(layout['path'], layout['value'])
  32. # Setting restore camera dialog to not display
  33. reg.set_ly_registry_value(restore_camera['path'], restore_camera['value'], restore_camera['new'])
  34. # Revert settings to original values
  35. def teardown():
  36. reg.set_ly_registry_value(layout['path'], layout['value'], layout['original'], value_type=winreg.REG_BINARY)
  37. reg.set_ly_registry_value(restore_camera['path'], restore_camera['value'], restore_camera['original'])
  38. request.addfinalizer(teardown)