PSLmodels / Tax-Brain

Tax-Brain is an integrator model for PSL tax models
http://taxbrain.pslmodels.org/
MIT License
9 stars 14 forks source link

Pytest failure #122

Closed jdebacker closed 4 years ago

jdebacker commented 4 years ago

After installing two additional dependencies to the taxbrain-dev environment (noted in Issue #121), I ran into the following error in the unit tests:

(taxbrain-dev) jason.debacker@x86_64-apple-darwin13 taxbrain % pytest
============================= test session starts ==============================
platform darwin -- Python 3.7.6, pytest-5.4.3, py-1.8.2, pluggy-0.13.1
rootdir: /Users/jason.debacker/repos/Tax-Brain
collected 11 items

tests/test_brain.py .........                                            [ 81%]
tests/test_cli.py .                                                      [ 90%]
tests/test_report.py F                                                   [100%]

=================================== FAILURES ===================================
_________________________________ test_report __________________________________

tb_static = <taxbrain.taxbrain.TaxBrain object at 0x7f83d0bd8fd0>

    def test_report(tb_static):
        """
        Ensure that all report files are created
        """
        outdir = "testreform"
        name = "Test Report"
        report(
            tb_static, name=name, outdir=outdir
        )
        dir_path = Path(outdir)
        assert dir_path.exists()
        assert Path(dir_path, "Test-Report.md").exists()
        assert Path(dir_path, "Test-Report.pdf").exists()
        assert Path(dir_path, "Test-Report.html").exists()
        diff_png = Path(dir_path, "difference_graph.png")
        diff_svg = Path(dir_path, "difference_graph.svg")
>       assert diff_png.exists() or diff_svg.exists()
E       AssertionError: assert (False or False)
E        +  where False = <bound method Path.exists of PosixPath('testreform/difference_graph.png')>()
E        +    where <bound method Path.exists of PosixPath('testreform/difference_graph.png')> = PosixPath('testreform/difference_graph.png').exists
E        +  and   False = <bound method Path.exists of PosixPath('testreform/difference_graph.svg')>()
E        +    where <bound method Path.exists of PosixPath('testreform/difference_graph.svg')> = PosixPath('testreform/difference_graph.svg').exists

tests/test_report.py:22: AssertionError
----------------------------- Captured stderr call -----------------------------
WARNING:bokeh.io.export:No SVG Plots were found.
WARNING:bokeh.io.export:No SVG Plots were found.
------------------------------ Captured log call -------------------------------
ERROR    weasyprint:images.py:231 Failed to load image at "file:///Users/jason.debacker/repos/Tax-Brain/taxbrain/testreform/difference_graph.svg" (URLError: <urlopen error [Errno 2] No such file or directory: '/Users/jason.debacker/repos/Tax-Brain/taxbrain/testreform/difference_graph.svg'>)
ERROR    weasyprint:images.py:231 Failed to load image at "file:///Users/jason.debacker/repos/Tax-Brain/taxbrain/testreform/dist_graph.svg" (URLError: <urlopen error [Errno 2] No such file or directory: '/Users/jason.debacker/repos/Tax-Brain/taxbrain/testreform/dist_graph.svg'>)

I have been unable to find where difference_graph.svg or dist_graph.svg would be created. @Peter-Metz, can you point me to the right place to look?

jdebacker commented 4 years ago

Talking with @Peter-Metz, it sounds like this test is of a function not yet a part TaxBrain master branch. @andersonfrailey Shall we remove this test or should we merge in the additional functionality?

andersonfrailey commented 4 years ago

The functionality is there (report.py), I think the images just aren't being exported by Bokeh. Are you using Bokeh 2.0+? It's possible that something changed with the new version we need to make a fix for. Also do you have selenium installed?

Peter-Metz commented 4 years ago

Looks like an issue with the SVG export -- the PNG's work just fine. I think we might need a line like:

plot.output_backend = "svg"

(Bokeh documentation), but the test still isn't passing locally. I can take another look tomorrow.

jdebacker commented 4 years ago

@andersonfrailey I'm using Bokeh 2.1.0 and Selenium 3.141.0.

andersonfrailey commented 4 years ago

Gotcha. I just got the same error. I think @Peter-Metz might be right about what's going on. I'll look into it as well.

andersonfrailey commented 4 years ago

Looks like @Peter-Metz was right. Once I added plot.output_backend="svg" everything passed. But, when I looked at the report generated all of the axis labels were missing. I think that cairo has trouble with SVG files. I think the best solution for now is to only use PNG files until we can get that figured out. I'll open up a PR to do that later today.

Here's what the missing labels in the report look like.

Screen Shot 2020-06-17 at 9 44 22 AM
Peter-Metz commented 4 years ago

I think the best solution for now is to only use PNG files until we can get that figured out.

+1

andersonfrailey commented 4 years ago

Resolved with PR #123. Thanks for the report, @jdebacker! Closing.