Skip to content

Testing plots

Ainur Gimadeev edited this page Oct 11, 2022 · 5 revisions

Introduction

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.

How it works

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.

Essential classes

Drawing

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 DrawingData class that has x and y fields. These fields will store the initial data that was visualized.
  • kwargs - keyword arguments that were used to visualize a data.

PlottingTest

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 all Drawing objects created after execution of the tested program.
  • new_figures() - returns the list of Drawings that were created before calling this method.

Supported plot types

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)

Clone this wiki locally