Skip to content

Commit

Permalink
Add a global conftest for doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
PProfizi committed Aug 19, 2022
1 parent 0534ef7 commit 078b647
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""This runs at the init of the pytest doctest session
Launch or connect to a persistent local DPF service to be shared in
pytest as a session fixture
"""
import re
import os

import pyvista as pv
import matplotlib as mpl

# enable off_screen plotting to avoid test interruption
pv.OFF_SCREEN = True
mpl.use("Agg")


def get_lighting():
"""Get lighting configuration.
Disable lighting when using OSMesa on Windows. See:
https://github.com/pyvista/pyvista/issues/3185
"""
pl = pv.Plotter(notebook=False, off_screen=True)
pl.add_mesh(pv.Sphere())
pl.show(auto_close=False)
gpu_info = pl.ren_win.ReportCapabilities();
pl.close()

regex = re.compile("OpenGL version string:(.+)\n")
version = regex.findall(gpu_info)[0]
return not(os.name == 'nt' and 'Mesa' in version)


pv.global_theme.lighting = get_lighting()

0 comments on commit 078b647

Please sign in to comment.