Example #1
0
    def test_random_visualizer_increased_tolerance(self):
        """
        Test that not close visualizers pass with increased tolerance
        """
        viz = RandomVisualizer(random_state=224).fit()
        viz.finalize()

        self.assert_images_similar(viz, tol=30)
Example #2
0
    def test_random_visualizer(self):
        """
        Test that a random visualization is correctly compared to a baseline
        """
        viz = RandomVisualizer(random_state=111).fit()
        viz.finalize()

        assert mpl.get_backend() == "agg"

        compare = self.assert_images_similar(viz, tol=1.0)
        assert_path_exists(compare.actual_image_path)
        assert_path_exists(compare.baseline_image_path)
    def test_random_visualizer_not_close(self):
        """
        Test that not close visualizers raise an assertion error.
        """
        # Baseline image random_state=225
        viz = RandomVisualizer(random_state=224).fit()
        viz.finalize()

        with pytest.raises(ImageComparisonFailure, match="images not close"):
            self.assert_images_similar(viz)

        # Assert there is a diff
        assert_path_exists(
            ACTUAL_IMAGES,
            "test_meta",
            "test_random_visualizer_not_close-failed-diff.png",
        )
Example #4
0
    def test_missing_baseline_image(self):
        """
        Test that a missing baseline image raises an exception
        """
        viz = RandomVisualizer(random_state=14).fit()
        viz.finalize()

        # Assert the baseline image does not exist
        assert_path_not_exists(BASELINE_IMAGES, "test_meta",
                               "test_missing_baseline_image.png")

        with pytest.raises(ImageComparisonFailure,
                           match="image does not exist"):
            self.assert_images_similar(viz)

        # Assert the actual image was created (to copy to baseline)
        assert_path_exists(ACTUAL_IMAGES, "test_meta",
                           "test_missing_baseline_image.png")
Example #5
0
    def test_random_visualizer_not_close(self):
        """
        Test that not close visualizers raise an assertion error.
        """
        # Baseline image random_state=224
        # NOTE: if regenerating baseline images, skip this one or change random state!
        viz = RandomVisualizer(random_state=225).fit()
        viz.finalize()

        with pytest.raises(ImageComparisonFailure, match="images not close"):
            # If failing, perhaps baseline images were regenerated? See note above.
            self.assert_images_similar(viz)

        # Assert there is a diff
        assert_path_exists(
            ACTUAL_IMAGES,
            "test_meta",
            "test_random_visualizer_not_close-failed-diff.png",
        )