report.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. # These methods are useful for testing purposes as they output different patterns of
  9. # lines that would appear in the console or various log files. These lines can then be
  10. # picked up via console/log monitoring or log parsing for automated/manual testing
  11. import azlmbr.legacy.general as general
  12. class Report:
  13. @staticmethod
  14. def info(msg: str) -> None:
  15. print(f"Info: {msg}")
  16. @staticmethod
  17. def success(success_message: str) -> None:
  18. print(f"Success: {success_message}")
  19. @staticmethod
  20. def failure() -> None:
  21. print("Failure: A pass condition has not passed in this test")
  22. @staticmethod
  23. def result(success_message: str, condition: bool) -> None:
  24. """
  25. This would be used for expecting a True output on some condition
  26. Example:
  27. level_loaded = EditorTestHelper.open_level("Example")
  28. Report.result("Example level loaded successfully", level_loaded)
  29. """
  30. if not isinstance(condition, bool):
  31. raise TypeError("condition argument must be a bool")
  32. if condition:
  33. Report.success(success_message)
  34. else:
  35. Report.failure()
  36. return condition