Testing paraview python script

I am trying to do testing (pytest) with my Paraview script. I was thinking that simple.ResetSession() cleans everything but when running the second test it renders object from the first although I reset after the first.
Which is the the way of testing paraview python?
Thanks

Please provide steps to reproduce your issue.

from paraview . simple import *

class TestBoth:

def test_sphere(self):
    model = Sphere(Center=[-1,0,0])
    render_view = GetActiveViewOrCreate('RenderView')
    rep = Show(model, render_view)
    SaveScreenshot("sphere.png", render_view)
    ResetSession()

def test_cilinder(self):
    model = Box(Center=[1,0,0])
    render_view = GetActiveViewOrCreate('RenderView')
    rep = Show(model, render_view)
    SaveScreenshot("box.png", render_view)
    ResetSession()

If I run each test alone I get the image of Sphere and Box respectively but if I run both tests box.png have the attached image. How can I say pv that forget every thing for the next test.box

Looks like ResetSession() is indeed quite limited. You can replace it by

Disconnect()
Connect()
1 Like

Worked, thanks:slightly_smiling_face:

from paraview . simple import *

class TestBoth:

def test_sphere(self):
    Connect()
    model = Sphere(Center=[-1,0,0])
    render_view = GetActiveViewOrCreate('RenderView')
    rep = Show(model, render_view)
    SaveScreenshot("sphere.png", render_view)
    Disconnect()

def test_cilinder(self):
    Connect()
    model = Box(Center=[1,0,0])
    render_view = GetActiveViewOrCreate('RenderView')
    rep = Show(model, render_view)
    SaveScreenshot("box.png", render_view)
    Disconnect()

Follow up issue : https://gitlab.kitware.com/paraview/paraview/issues/19516