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
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 |