Doctest within ParaVIEW

Dear Community,

I would like to run Doctests within Python. I created a simple testClass to describe my problem:

class testClass:
  >>> import sys
  >>> render = "paraview.simple" in sys.modules
  >>> if render:
  ...   print("ParaVIEW available.")
  def __init__( self ) -> None:
def testAndShow():
  import testClass
  import doctest

Then I would like to run ParaVIEW and execute the following within the Python shell:

>>> from paraview.simple import *
>>> from testClass import *
>>> testAndShow()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/ati/tmp/dtOO-application/pythonOO/", line 26, in testAndShow
  File "/usr/lib64/python3.6/", line 1951, in testmod
  File "/usr/lib64/python3.6/", line 1445, in run
    encoding = save_stdout.encoding
AttributeError: 'vtkPythonStdStreamCaptureHelper' object has no attribute 'encoding'

So, what’S my mistake?

Thank you for your support.

It looks like our stream shim isn’t as transparent as it should be. Cc: @dgobbi

Python documents it here. It looks like we should also add .errors and .closed in addition to .encoding.

Does it mean that the stream shim will be extended to support the doctests within the paraview python shell?

We should (and likely will eventually). We should really open an issue to track it. I’ve done that here: