Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust test_GraphicsBitmaps.py for newer renderpm #3767

Merged
merged 2 commits into from
Oct 22, 2021

Conversation

emollier
Copy link
Contributor

Greetings,

Starting with reportlab 3.6, the RenderPM error message relative to
missing fonts does not start with "Can't setFont(" any more, but
"Error in setFont(" instead. This breaks the test suite in case
the font is indeed missing, while it used to be skipped instead.
The main symptom is the test suite failing with error:

Traceback (most recent call last):
  File "/tmp/autopkgtest-lxc.czuqoy9m/downtmp/autopkgtest_tmp/Tests/run_tests.py", line 275, in runTest
    suite = loader.loadTestsFromName(name)
  File "/usr/lib/python3.9/unittest/loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
  File "/tmp/autopkgtest-lxc.czuqoy9m/downtmp/autopkgtest_tmp/Tests/test_GraphicsBitmaps.py", line 119, in <module>
    real_test()
  File "/tmp/autopkgtest-lxc.czuqoy9m/downtmp/autopkgtest_tmp/Tests/test_GraphicsBitmaps.py", line 92, in real_test
    compare_plot.draw_to_file(output_file, "Testing Scatter Plots")
  File "/usr/lib/python3/dist-packages/Bio/Graphics/Comparative.py", line 96, in draw_to_file
    return _write(cur_drawing, output_file, self.output_format)
  File "/usr/lib/python3/dist-packages/Bio/Graphics/__init__.py", line 88, in _write
    return drawmethod.drawToFile(drawing, output_file, format, dpi=dpi)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 692, in drawToFile
    c = drawToPMCanvas(d, dpi=dpi, bg=bg, configPIL=configPIL, showBoundary=showBoundary,backend=backend)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 678, in drawToPMCanvas
    draw(d, c, 0, 0, showBoundary=showBoundary)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 49, in draw
    R.draw(renderScaledDrawing(drawing), canvas, x, y, showBoundary=showBoundary)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderbase.py", line 185, in draw
    self.initState(x,y)  #this is the push()
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 96, in initState
    self.applyState()
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 90, in applyState
    self._canvas.setFont(s['fontName'], s['fontSize'])
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 406, in setFont
    _setFont(self._gs,fontName,fontSize)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/utils.py", line 42, in setFont
    _errorDump(fontName,fontSize)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/utils.py", line 29, in _errorDump
    rl_exec(code,dict(RenderPMError=RenderPMError))
  File "<string>", line 1, in <module>
reportlab.graphics.utils.RenderPMError: Error in setFont('Times-Roman',10) missing the T1 files?
Originally <class 'TypeError'>: makeT1Font() argument 2 must be str, not None

A full log is available on Debian continous integration platform.

This patch adds a pattern to match for the new error message as well.

  • I hereby agree to dual licence this and any previous contributions under both
    the Biopython License Agreement AND the BSD 3-Clause License.

  • I have read the CONTRIBUTING.rst file, have run pre-commit locally,
    and understand that AppVeyor and TravisCI will be used to confirm the Biopython unit
    tests and style checks pass with these changes.

  • I have added my name to the alphabetical contributors listings in the files
    NEWS.rst and CONTRIB.rst as part of this pull request, am listed
    already, or do not wish to be listed. (This acknowledgement is optional.)

Starting with reportlab 3.6, the RenderPM error message relative to
missing fonts does not start with "Can't setFont(" any more, but
"Error in setFont(" instead.  This breaks the test suite in case
the font is indeed missing, while it used to be skipped instead.
The main symptom is the test suite failing with error:

Traceback (most recent call last):
  File "/tmp/autopkgtest-lxc.czuqoy9m/downtmp/autopkgtest_tmp/Tests/run_tests.py", line 275, in runTest
    suite = loader.loadTestsFromName(name)
  File "/usr/lib/python3.9/unittest/loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
  File "/tmp/autopkgtest-lxc.czuqoy9m/downtmp/autopkgtest_tmp/Tests/test_GraphicsBitmaps.py", line 119, in <module>
    real_test()
  File "/tmp/autopkgtest-lxc.czuqoy9m/downtmp/autopkgtest_tmp/Tests/test_GraphicsBitmaps.py", line 92, in real_test
    compare_plot.draw_to_file(output_file, "Testing Scatter Plots")
  File "/usr/lib/python3/dist-packages/Bio/Graphics/Comparative.py", line 96, in draw_to_file
    return _write(cur_drawing, output_file, self.output_format)
  File "/usr/lib/python3/dist-packages/Bio/Graphics/__init__.py", line 88, in _write
    return drawmethod.drawToFile(drawing, output_file, format, dpi=dpi)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 692, in drawToFile
    c = drawToPMCanvas(d, dpi=dpi, bg=bg, configPIL=configPIL, showBoundary=showBoundary,backend=backend)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 678, in drawToPMCanvas
    draw(d, c, 0, 0, showBoundary=showBoundary)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 49, in draw
    R.draw(renderScaledDrawing(drawing), canvas, x, y, showBoundary=showBoundary)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderbase.py", line 185, in draw
    self.initState(x,y)  #this is the push()
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 96, in initState
    self.applyState()
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 90, in applyState
    self._canvas.setFont(s['fontName'], s['fontSize'])
  File "/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py", line 406, in setFont
    _setFont(self._gs,fontName,fontSize)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/utils.py", line 42, in setFont
    _errorDump(fontName,fontSize)
  File "/usr/lib/python3/dist-packages/reportlab/graphics/utils.py", line 29, in _errorDump
    rl_exec(code,dict(RenderPMError=RenderPMError))
  File "<string>", line 1, in <module>
reportlab.graphics.utils.RenderPMError: Error in setFont('Times-Roman',10) missing the T1 files?
Originally <class 'TypeError'>: makeT1Font() argument 2 must be str, not None

A full log is available on Debian continous integration platform [1].

[1]: https://ci.debian.net/data/autopkgtest/testing/arm64/p/python-biopython/16089190/log.gz

This patch adds a pattern to match for the new error message as well.
@codecov
Copy link

codecov bot commented Oct 22, 2021

Codecov Report

Merging #3767 (d01e800) into master (d72560f) will decrease coverage by 1.67%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3767      +/-   ##
==========================================
- Coverage   83.81%   82.13%   -1.68%     
==========================================
  Files         318      298      -20     
  Lines       53063    49943    -3120     
==========================================
- Hits        44475    41022    -3453     
- Misses       8588     8921     +333     
Impacted Files Coverage Δ
Bio/Phylo/CDAOIO.py 4.46% <0.00%> (-80.36%) ⬇️
Bio/phenotype/pm_fitting.py 12.28% <0.00%> (-75.44%) ⬇️
Bio/PDB/mmtf/__init__.py 28.57% <0.00%> (-61.91%) ⬇️
Bio/Graphics/__init__.py 25.00% <0.00%> (-58.34%) ⬇️
Bio/Phylo/CDAO.py 42.85% <0.00%> (-57.15%) ⬇️
Bio/Phylo/_utils.py 25.00% <0.00%> (-52.41%) ⬇️
Bio/codonalign/codonseq.py 44.16% <0.00%> (-44.31%) ⬇️
Bio/Phylo/_cdao_owl.py 89.47% <0.00%> (-10.53%) ⬇️
Bio/KEGG/KGML/KGML_pathway.py 73.58% <0.00%> (-6.67%) ⬇️
Bio/motifs/jaspar/db.py 3.04% <0.00%> (-5.33%) ⬇️
... and 27 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d72560f...d01e800. Read the comment docs.

@peterjc peterjc merged commit 1b3b186 into biopython:master Oct 22, 2021
@peterjc
Copy link
Member

peterjc commented Oct 22, 2021

Thank you!

Lucioric2000 pushed a commit to Lucioric2000/biopython that referenced this pull request Nov 14, 2021
Starting with reportlab 3.6, the RenderPM error message relative to
missing fonts does not start with "Can't setFont(" any more, but
"Error in setFont(" instead.  This breaks the test suite in case
the font is indeed missing, while it used to be skipped instead.
The main symptom is the test suite failing with error:

Traceback (most recent call last):
...
reportlab.graphics.utils.RenderPMError: Error in setFont('Times-Roman',10) missing the T1 files?
Originally <class 'TypeError'>: makeT1Font() argument 2 must be str, not None

A full log is available on Debian continuous integration platform [1].

[1]: https://ci.debian.net/data/autopkgtest/testing/arm64/p/python-biopython/16089190/log.gz

This patch adds a pattern to match for the new error message as well.
@emollier emollier deleted the renderpm-font branch December 18, 2022 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants