Editor_TestClass.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. class BaseClass():
  7. # Description:
  8. # Helper class to encapsulate testing logic
  9. @staticmethod
  10. def check_result(result, msg):
  11. from editor_python_test_tools.utils import Report
  12. if not result:
  13. Report.result(msg, False)
  14. raise Exception(msg + " : FAILED")
  15. def test_case(self, callback, level='Base'):
  16. from editor_python_test_tools.utils import Report
  17. from editor_python_test_tools.utils import TestHelper
  18. import azlmbr.legacy.general
  19. # required for automated tests
  20. TestHelper.init_idle()
  21. # open the test level
  22. TestHelper.open_level(directory="", level=level)
  23. azlmbr.legacy.general.idle_wait_frames(1)
  24. # run the test case callback
  25. Report.start_test(callback)
  26. # all tests worked
  27. Report.result(f"{callback} all tests worked", True)