# Testing paraview python script

**URL:** https://discourse.paraview.org/t/testing-paraview-python-script/3147
**Category:** ParaView Support
**Created:** [December 9, 2019, 12:24pm UTC](https://discourse.paraview.org/t/testing-paraview-python-script/3147 "2019-12-09T12:24:16Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![gilcu2](https://discourse.paraview.org/user_avatar/discourse.paraview.org/gilcu2/32/2183_2.png) [@gilcu2](https://discourse.paraview.org/u/gilcu2)
#### Post date: [December 9, 2019, 12:24pm UTC](https://discourse.paraview.org/t/testing-paraview-python-script/3147/1 "2019-12-09T12:24:16Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [December 9, 2019, 12:28pm UTC](https://discourse.paraview.org/t/testing-paraview-python-script/3147/2 "2019-12-09T12:28:44Z")

</div>

Please provide steps to reproduce your issue.

---

<div class="post-metadata">

### Author: ![gilcu2](https://discourse.paraview.org/user_avatar/discourse.paraview.org/gilcu2/32/2183_2.png) [@gilcu2](https://discourse.paraview.org/u/gilcu2)
#### Post date: [December 9, 2019, 12:46pm UTC](https://discourse.paraview.org/t/testing-paraview-python-script/3147/3 "2019-12-09T12:46:27Z")

</div>

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](https://discourse.paraview.org/uploads/default/original/2X/6/68cba632ebd38f0ea2adba68c327bec8b5a7917d.png)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [December 9, 2019, 12:49pm UTC](https://discourse.paraview.org/t/testing-paraview-python-script/3147/4 "2019-12-09T12:49:41Z")

</div>

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

```
Disconnect()
Connect()
```

---

<div class="post-metadata">

### Author: ![gilcu2](https://discourse.paraview.org/user_avatar/discourse.paraview.org/gilcu2/32/2183_2.png) [@gilcu2](https://discourse.paraview.org/u/gilcu2)
#### Post date: [December 9, 2019, 12:51pm UTC](https://discourse.paraview.org/t/testing-paraview-python-script/3147/5 "2019-12-09T12:51:48Z")

</div>

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()
```

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [December 10, 2019, 9:59am UTC](https://discourse.paraview.org/t/testing-paraview-python-script/3147/6 "2019-12-10T09:59:35Z")

</div>

Follow up issue : [https://gitlab.kitware.com/paraview/paraview/issues/19516](https://gitlab.kitware.com/paraview/paraview/issues/19516)
