docs.unity3d.com
    Show / Hide Table of Contents

    Class PythonTestUtils

    Implement waiting methods. We leverage the UnityTest attribute for our waits. Contrary to regular C#, we can nest yield return calls and get the "intuitive" behaviour.

    Inheritance
    System.Object
    PythonTestUtils
    Namespace: UnityEditor.Scripting.Python.Tests
    Syntax
    public static class PythonTestUtils : object

    Methods

    WaitForProcessEnd(Object, Double)

    Returns an IEnumerator to await the end of process. Asserts if the timeout is reached.

    Declaration
    public static IEnumerator WaitForProcessEnd(dynamic process, double timeout = 5)
    Parameters
    Type Name Description
    System.Object process

    The process to wait on. A python popen object

    Double timeout

    The maximum length of time for to wait the process to end, in seconds

    Returns
    Type Description
    IEnumerator

    WaitForSecondsDuringUnityTest(Double, Func<Boolean>)

    Because UnityTests can only yield return null (or an IEnumerator yield returning null), we cannot use Unity's WaitForSeconds. Make our own version. If a condition function was given, if the condition never evaluated to True during the loop, raises a Assert.Fail

    Declaration
    public static IEnumerator WaitForSecondsDuringUnityTest(double waitTime, Func<bool> condition = null)
    Parameters
    Type Name Description
    Double waitTime

    The interval of time to wait for, in seconds.

    Func<Boolean> condition

    A function returning a boolean. If the function returns true, exit early.

    Returns
    Type Description
    IEnumerator
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023