Skip to content

Various TestPlotMatplotlib tests fail 0.17.0 on older Debian nd120 (bookworm (and likely Ubuntus ) #320

@yarikoptic

Description

@yarikoptic

Tried to update backports for neurodebian to discover that

con-duct_0.17.0-1~nd120+1_amd64.build:FAILED test/test_suite.py::TestPlotMatplotlib::test_matplotlib_plot_info_json
con-duct_0.17.0-1~nd120+1_amd64.build:FAILED test/test_suite.py::TestPlotMatplotlib::test_matplotlib_plot_interactive_backend_with_get_backend
con-duct_0.17.0-1~nd120+1_amd64.build:FAILED test/test_suite.py::TestPlotMatplotlib::test_matplotlib_plot_sanity - ...

and in detail

______________ TestPlotMatplotlib.test_matplotlib_plot_info_json _______________

self = <test_suite.TestPlotMatplotlib testMethod=test_matplotlib_plot_info_json>
mock_plot_save = <MagicMock name='savefig' id='140489145670672'>

    @patch("matplotlib.pyplot.savefig")
    def test_matplotlib_plot_info_json(self, mock_plot_save: MagicMock) -> None:
        """When user passes info.json, usage.json is retrieved and used"""
        args = argparse.Namespace(
            command="plot",
            file_path="test/data/mriqc-example/info.json",
            output="outfile.png",
            func=plot.matplotlib_plot,
            log_level="NONE",
            min_ratio=3.0,
        )
>       assert main.execute(args) == 0
E       AssertionError: assert 1 == 0
E        +  where 1 = <function execute at 0x7fc6a8adafc0>(Namespace(command='plot', file_path='test/data/mriqc-example/info.json', output='outfile.png', func=<function matplotlib_plot at 0x7fc6a8bafba0>, log_level='NONE', min_ratio=3.0))
E        +    where <function execute at 0x7fc6a8adafc0> = main.execute

test/test_suite.py:316: AssertionError
_ TestPlotMatplotlib.test_matplotlib_plot_interactive_backend_with_get_backend _

self = <test_suite.TestPlotMatplotlib testMethod=test_matplotlib_plot_interactive_backend_with_get_backend>
_mock_get_backend = <MagicMock name='get_backend' id='140488678635536'>
mock_show = <MagicMock name='show' id='140488678939536'>

    @patch("matplotlib.pyplot.show")
    @patch("matplotlib.get_backend", return_value="tkagg")
    def test_matplotlib_plot_interactive_backend_with_get_backend(
        self,
        _mock_get_backend: MagicMock,
        mock_show: MagicMock,
    ) -> None:
        """Test that plotting without output in interactive backend calls plt.show() successfully."""
    
        args = argparse.Namespace(
            command="plot",
            file_path="test/data/mriqc-example/usage.json",
            output=None,  # No output file specified
            func=plot.matplotlib_plot,
            log_level="NONE",
            min_ratio=3.0,
        )
        result = main.execute(args)
>       assert result == 0
E       assert 1 == 0

test/test_suite.py:395: AssertionError
________________ TestPlotMatplotlib.test_matplotlib_plot_sanity ________________

self = <test_suite.TestPlotMatplotlib testMethod=test_matplotlib_plot_sanity>
mock_plot_save = <MagicMock name='savefig' id='140488674313680'>

    @patch("matplotlib.pyplot.savefig")
    def test_matplotlib_plot_sanity(self, mock_plot_save: MagicMock) -> None:
        args = argparse.Namespace(
            command="plot",
            file_path="test/data/mriqc-example/usage.json",
            output="outfile.png",
            func=plot.matplotlib_plot,
            log_level="NONE",
            min_ratio=3.0,
        )
>       assert main.execute(args) == 0
E       AssertionError: assert 1 == 0
E        +  where 1 = <function execute at 0x7fc6a8adafc0>(Namespace(command='plot', file_path='test/data/mriqc-example/usage.json', output='outfile.png', func=<function matplotlib_plot at 0x7fc6a8bafba0>, log_level='NONE', min_ratio=3.0))
E        +    where <function execute at 0x7fc6a8adafc0> = main.execute

test/test_suite.py:275: AssertionError

do you see obvious fix? could be tested easily on e.g. docker run --it --rm neurodebian:nd120 and there on env

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions