# vtk headless for testing

**URL:** https://discourse.vtk.org/t/vtk-headless-for-testing/1006
**Category:** Support
**Created:** [May 22, 2019, 6:58am UTC](https://discourse.vtk.org/t/vtk-headless-for-testing/1006 "2019-05-22T06:58:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![nschloe](https://discourse.vtk.org/user_avatar/discourse.vtk.org/nschloe/32/461_2.png) [@nschloe](https://discourse.vtk.org/u/nschloe)
#### Post date: [May 22, 2019, 6:58am UTC](https://discourse.vtk.org/t/vtk-headless-for-testing/1006/1 "2019-05-22T06:58:17Z")

</div>

I have a simple VTK Python code that plots a tetrahedron:

```python
# plot a tetrahedron
import numpy
import vtk

node_coords = numpy.array(
    [
        [1.0, 0.0, -1.0 / numpy.sqrt(8)],
        [-0.5, +numpy.sqrt(3.0) / 2.0, -1.0 / numpy.sqrt(8)],
        [-0.5, -numpy.sqrt(3.0) / 2.0, -1.0 / numpy.sqrt(8)],
        [0.0, 0.0, numpy.sqrt(2.0) - 1.0 / numpy.sqrt(8)],
    ]
) / numpy.sqrt(3.0)
cells = numpy.array([[0, 1, 2, 3]])
cell_id = 0
line_width = 3.0

def get_line_actor(x0, x1, line_width=1.0):
    source = vtk.vtkLineSource()
    source.SetPoint1(x0)
    source.SetPoint2(x1)
    # mapper
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(source.GetOutputPort())
    # actor
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    # color actor
    actor.GetProperty().SetColor(0, 0, 0)
    actor.GetProperty().SetLineWidth(line_width)
    return actor

# Visualize
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)

for ij in [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]]:
    x0, x1 = node_coords[cells[cell_id][ij]]
    renderer.AddActor(get_line_actor(x0, x1, line_width))
renderer.SetBackground(1.0, 1.0, 1.0)

renderWindow.Render()
renderWindowInteractor.Start()

```

[![enter image description here](https://discourse.vtk.org/uploads/default/original/1X/4026818a74af23b98698ed91bcd03f1d38ece335.png)](https://discourse.vtk.org/uploads/default/original/1X/4026818a74af23b98698ed91bcd03f1d38ece335.png)

I would now like to add continuous integration testing for this code (which runs in in a headless environment), but all I’m getting is

```auto
Received 'aborted' signal

```

Adding code for closing the window

```python
# renderWindowInteractor.Start()

render_window.Finalize()
del render_window, render_window_interactor

```

does not help.

How to use VTK in a headless environment?
