Skip to content

Commit

Permalink
DEBUG-log font-matching results, and print failing logs on CI.
Browse files Browse the repository at this point in the history
pytest will only actually output logs if the test fail.
  • Loading branch information
anntzer committed Jan 21, 2019
1 parent 5702999 commit 5ce631c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ environment:
global:
PYTHONIOENCODING: UTF-8
PYTEST_ARGS: -raR --numprocesses=auto --timeout=300 --durations=25
--cov-report= --cov=lib -m "not network"
--cov-report= --cov=lib -m "not network" --log-level=DEBUG

matrix:
# theoretically the CONDA_INSTALL_LOCN could be only two: one for 32bit,
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ env:
- NPROC=2
- OPENBLAS_NUM_THREADS=1
- PYTHONFAULTHANDLER=1
- PYTEST_ADDOPTS="-raR --maxfail=50 --timeout=300 --durations=25 --cov-report= --cov=lib -n $NPROC"
- PYTEST_ADDOPTS="-raR --maxfail=50 --timeout=300 --durations=25 --cov-report= --cov=lib -n $NPROC --log-level=DEBUG"
- RUN_PYTEST=1
- RUN_FLAKE8=

Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- script: |
env
pytest --junitxml=junit/test-results.xml -raR --maxfail=50 --timeout=300 --durations=25 --cov-report= --cov=lib -n 2
pytest --junitxml=junit/test-results.xml -raR --maxfail=50 --timeout=300 --durations=25 --cov-report= --cov=lib -n 2 --log-level=DEBUG
displayName: 'pytest'
- task: PublishTestResults@2
Expand Down
21 changes: 10 additions & 11 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,10 +1222,9 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default,

if not isinstance(prop, FontProperties):
prop = FontProperties(prop)
fname = prop.get_file()

fname = prop.get_file()
if fname is not None:
_log.debug('findfont returning %s', fname)
return fname

if fontext == 'afm':
Expand All @@ -1236,19 +1235,19 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default,
best_score = 1e64
best_font = None

_log.debug('findfont: Matching %s.', prop)
for font in fontlist:
if (directory is not None and
Path(directory) not in Path(font.fname).parents):
continue
# Matching family should have highest priority, so it is multiplied
# by 10.0
score = \
self.score_family(prop.get_family(), font.name) * 10.0 + \
self.score_style(prop.get_style(), font.style) + \
self.score_variant(prop.get_variant(), font.variant) + \
self.score_weight(prop.get_weight(), font.weight) + \
self.score_stretch(prop.get_stretch(), font.stretch) + \
self.score_size(prop.get_size(), font.size)
# Matching family should have top priority, so multiply it by 10.
score = (self.score_family(prop.get_family(), font.name) * 10
+ self.score_style(prop.get_style(), font.style)
+ self.score_variant(prop.get_variant(), font.variant)
+ self.score_weight(prop.get_weight(), font.weight)
+ self.score_stretch(prop.get_stretch(), font.stretch)
+ self.score_size(prop.get_size(), font.size))
_log.debug('findfont: score(%s) = %s', font, score)
if score < best_score:
best_score = score
best_font = font
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/tests/test_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def test_movie_writer_registry():
reason="animation writer not installed")
@pytest.mark.parametrize("method_name", ["to_html5_video", "to_jshtml"])
def test_embed_limit(method_name, caplog, tmpdir):
caplog.set_level("WARNING")
with tmpdir.as_cwd():
with mpl.rc_context({"animation.embed_limit": 1e-6}): # ~1 byte.
getattr(make_animation(frames=1), method_name)()
Expand Down

0 comments on commit 5ce631c

Please sign in to comment.