test_plot.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:supvisors 作者: julien6387 项目源码 文件源码
def test_plot(self):
        """ Test a simple plot.
        Complex to test anything. Just check that there is no exception. """
        from supvisors.plot import StatisticsPlot
        from supvisors.viewimage import StatsImage
        plot = StatisticsPlot()
        self.assertEqual({}, plot.ydata)
        # add series of data
        plot.add_plot('dummy_title_1', 'unit_1', [1, 2, 3])
        plot.add_plot('dummy_title_2', 'unit_2', [10, 20, 30])
        self.assertDictEqual({('dummy_title_1', 'unit_1'): [1, 2, 3], ('dummy_title_2', 'unit_2'): [10, 20, 30]}, plot.ydata)
        # export image in buffer
        contents = StatsImage()
        plot.export_image(contents)
        # test that result is a PNG file
        self.assertEqual('png', imghdr.what('', h=contents.contents.getvalue()))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号