Skip to content

Examples

ThomasPRZilliox edited this page Mar 25, 2025 · 4 revisions

PyTest Examples

Example 1 - Plot

In that first example the Python script (using the pytest framework) will do the following:

  1. Check that the front most VI is "example 1 - plot.vi"
  2. Click on the button "Generate new plots"
  3. Store the new value of the graph
  4. Click again on the button "Generate new plots"
  5. Store the new value of the graph
  6. Compare the two values, the test is passed if they differ.

example 1 - plot

Example 2 - Value

In that second example the Python script (using the pytest framework) will do the following:

  1. Check that the front most VI is "example 2 - value.vi"
  2. Using the parametrized function of pytest, set a value to control labelled "myNumber"
  3. Then get the value of the control labelled "myNumber" and the boolean indicator "greater"
  4. If the boolean indicator "greater" si TRUE when "myNumber" is > 5, then the test is passed

example 2 - value

Example 3 - Subpanel

In that third example the Python script (using the pytest framework) will do the following:

  1. Check that the front most VI is "example 3 - subpanel.vi"
  2. Click on the Sub Panel 1 control
  3. Check that the supbanel is displaying the appropriate VI (which is similar to example 1)
  4. Repeate the test of example 1
  5. Click on the Sub Panel 2 control
  6. Check that the supbanel is displaying the appropriate VI (which is similar to example 2)
  7. Repeate the test of example 2

example 3 - Subpanel

Example 4 - String

In that fourth example the Python script (using the pytest framework) will do the following:

  1. Check that the front most VI is "example 4 - string.vi"
  2. Update the control "String" in the following way (Set it to "Hello", read it and add to its current value " World")
  3. Check that the string control now display "Hello World"
  4. Check that the tree control is unselected.
  5. Select the parent item of the tree and check that it is indeed selected
  6. Select the items "Child 1" and "Child 2" then ensure they are both selected

example 4 - String

Clone this wiki locally