-
Notifications
You must be signed in to change notification settings - Fork 11
Testing plots
This wiki page will describe the process of testing plots in python using hs-test-python library. We will describe only plotting related features of the library. The basics of the testing process can be found in the Writing tests section.
The testing library supports the following python data visualization libraries:
- matplotlib
- pandas
- seaborn
After running the tests, the hs-test-python library will intercept the creation of plots, and you will be able to access these plots' data.
The class that represents a plot that is plotted using data visualization libraries. It has the following fields:
- library - describes the name of the library that have been used to plot a data.
- type - is a type of plot.
- data - the instance of the
DrawingDataclass that hasxandyfields. These fields will store the initial data that was visualized. - kwargs - keyword arguments that were used to visualize a data.
The main class that is used to test plots is PlottingTest class. It can be imported from hstest module:
from hstest import PlottingTest
You should write your test case inside a class that iherits the PlottingTest class.
It has the following methods:
-
all_figures()- returns the list of allDrawingobjects created after execution of the tested program. -
new_figures()- returns the list ofDrawingsthat were created before calling this method.
For now it supports the following plot types:
-
histplot (
matplotlib,pandas,seaborn) -
barplot (
matplotlib,pandas,seaborn) - horizontal barplot (the same as barplot)
-
pieplot (
matplotlib,pandas)