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

Fix logging bugs formerly suppressed by pytest #5209

Merged
merged 2 commits into from
Jul 29, 2020

Conversation

jdavies-st
Copy link
Collaborator

@jdavies-st jdavies-st commented Jul 29, 2020

Pin pytest<6 because of pytest-doctestplus imcompatibility (for now).

This fixes some logging bugs in cube_build where None objects were getting passed through an %f formatter in log messages.

$ pytest jwst/cube_build/tests/test_miri_cubepars.py::test_miri_cubepars_multiple_bands
========================================= test session starts =========================================
platform darwin -- Python 3.7.7, pytest-6.0.0, py-1.9.0, pluggy-0.13.1
rootdir: /Users/jdavies/dev/jwst, configfile: setup.cfg
plugins: doctestplus-0.7.0, requests-mock-1.8.0, asdf-2.7.0, ci-watson-0.5, cov-2.10.0, xdist-1.34.0, openfiles-0.5.0, forked-1.3.0
collected 1 item                                                                                      

jwst/cube_build/tests/test_miri_cubepars.py F                                                   [100%]

============================================== FAILURES ===============================================
__________________________________ test_miri_cubepars_multiple_bands __________________________________

_jail = '/private/var/folders/jg/by5st33j7ps356dgb4kn8w900001n5/T/pytest-of-jdavies/pytest-20/test_miri_cubepars_multiple_ba0'
miri_cube_pars = '/private/var/folders/jg/by5st33j7ps356dgb4kn8w900001n5/T/pytest-of-jdavies/pytest-20/cube_pars0/miri_cube_pars.fits'

<snip>

>       this_cube.determine_cube_parameters()

/Users/jdavies/dev/jwst/jwst/cube_build/tests/test_miri_cubepars.py:456: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Users/jdavies/dev/jwst/jwst/cube_build/ifu_cube.py:1099: in determine_cube_parameters
    log.debug('spectral size %f', self.spectral_size)

<snip>

/Users/jdavies/miniconda3/envs/test/lib/python3.7/logging/__init__.py:608: in format
    record.message = record.getMessage()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <LogRecord: stpipe, 10, /Users/jdavies/dev/jwst/jwst/cube_build/ifu_cube.py, 1099, "spectral size %f">

    def getMessage(self):
        """
        Return the message for this LogRecord.
    
        Return the message for this LogRecord after merging any user-supplied
        arguments with the message.
        """
        msg = str(self.msg)
        if self.args:
>           msg = msg % self.args
E           TypeError: must be real number, not NoneType

/Users/jdavies/miniconda3/envs/test/lib/python3.7/logging/__init__.py:369: TypeError
======================================= short test summary info =======================================
FAILED jwst/cube_build/tests/test_miri_cubepars.py::test_miri_cubepars_multiple_bands - TypeError: m...
========================================== 1 failed in 1.18s ==========================================

These were not showing up in our unit tests before because pytest used to suppress them. That is no longer the case in pytest 6.0. See https://docs.pytest.org/en/stable/changelog.html#id37 (pytest-dev/pytest#6433)

I went ahead and changed all the log messages in these 2 modules to use f-strings for consistency.

Also, I removed some legacy code for handling the pytest schema checker outside of entry points when using old versions of asdf which can no longer be used with this package.

Copy link
Collaborator

@hbushouse hbushouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov
Copy link

codecov bot commented Jul 29, 2020

Codecov Report

Merging #5209 into master will decrease coverage by 0.00%.
The diff coverage is 36.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5209      +/-   ##
==========================================
- Coverage   52.46%   52.46%   -0.01%     
==========================================
  Files         406      406              
  Lines       36331    36333       +2     
  Branches     5628     5629       +1     
==========================================
  Hits        19061    19061              
- Misses      16096    16098       +2     
  Partials     1174     1174              
Flag Coverage Δ
#unit 52.46% <36.84%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
jwst/cube_build/cube_build_step.py 26.21% <33.33%> (ø)
jwst/cube_build/ifu_cube.py 23.10% <38.46%> (ø)
jwst/pipeline/calwebb_spec2.py 33.33% <0.00%> (-0.43%) ⬇️
jwst/fringe/fringe.py 100.00% <0.00%> (ø)
jwst/associations/lib/rules_level3.py 96.15% <0.00%> (ø)

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 1286b38...40253f0. Read the comment docs.

@hbushouse hbushouse merged commit adae761 into spacetelescope:master Jul 29, 2020
@jdavies-st jdavies-st deleted the pytest-logging-fixes branch July 29, 2020 21:12
Copy link
Contributor

@jemorrison jemorrison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those changes look good.

stscieisenhamer pushed a commit to stscieisenhamer/jwst that referenced this pull request Aug 7, 2020
* Fix logging bugs formerly suppressed by pytest

* Pin pytest<6.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants