CI systems typically set the environment variable
CI as a de facto standard for easy CI detection.
Here are details of several popular CI services:
Detect CI inside Python
Pytest handles conditional tests well. This allows one to test Matplotlib on their local computer, while skipping those plotting tests on CI.
import os import pytest CI = os.environ.get('CI') in ('True', 'true') @pytest.mark.skipif(CI, reason="no plots for CI") def test_myfun(): from matplotlib.pyplot import figure,show ...