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

CIs error on deprecation warning #708

Merged
merged 16 commits into from
Feb 14, 2020

Conversation

guyer
Copy link
Member

@guyer guyer commented Feb 7, 2020

Cause DeprecationWarning to raise an Exception when the CIs run the tests.

Try to prevent things like #703 from sneaking up on us

* Change "FORTRAN" array ordering to 'F'

`order="FORTRAN"` has been deprecated in numpy for awhile
and has been [removed in numpy 1.18](https://numpy.org/devdocs/release/1.18.0-notes.html)
The version here [generates deprecations](https://app.circleci.com/jobs/github/usnistgov/fipy/2031)
and [ez_setup.py itself is deprecated](pypa/setuptools#581)
The itsolvers classes aren't written right (e.g., `solve()` doesn't
return anything) and don't encapsulate anything we care about.
The `krylov` calls are set up the way we expect.
Raising errors for all of `python setup.py test` causes
errors for deprecations in things we don't control, like versioneer.
@guyer guyer requested review from tkphd and wd15 February 11, 2020 16:11
@wd15
Copy link
Contributor

wd15 commented Feb 11, 2020

This isn't working for me. If say I add

import warnings

def my_func():
    """
    >>> my_func()
    """
    # warnings.simplefilter(
    #     "error",
    #     category=DeprecationWarning
    # )
    warnings.warn(
        "in my_func",
        DeprecationWarning
    )
    #raise Exception('hello')

near the top of fipy/variable.py and run python setup.py test --deprecation-errors --modules then I'm seeing a deprecation warning, but not an error. Is that the correct behavior. I guess we don't want it to fail on our own deprecation warnings. How does it know whether it's our own or an outside modules deprecation warning?

@wd15
Copy link
Contributor

wd15 commented Feb 11, 2020

Also, we're getting /home/wd15/git/fipy/fipy/tests/test.py:237: PkgResourcesDeprecationWarning: Parameters to load are deprecated. Call .resolve and .require separately. (I'm getting). Should that fail?

@guyer
Copy link
Member Author

guyer commented Feb 11, 2020

@wd15 I saw the PkgResourcesDeprecationWarning at one point, but then couldn't reproduce it. Can you post a traceback?

@guyer
Copy link
Member Author

guyer commented Feb 11, 2020

Nevermind. I see, there is no traceback.

@guyer
Copy link
Member Author

guyer commented Feb 11, 2020

PkgResourcesDeprecationWarning both derives from Warning, not DeprecationWarning, and it gets called before the tests are run. If it errored, it would just prevent the tests from running at all.

@guyer
Copy link
Member Author

guyer commented Feb 11, 2020

@wd15 I get

======================================================================
FAIL: my_func (fipy.variables.variable)
Doctest: fipy.variables.variable.my_func
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/guyer/anaconda/envs/fipy/lib/python2.7/doctest.py", line 2226, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for fipy.variables.variable.my_func
  File "/Users/guyer/Documents/research/FiPy/fipy/fipy/variables/variable.py", line 21, in my_func

----------------------------------------------------------------------
File "/Users/guyer/Documents/research/FiPy/fipy/fipy/variables/variable.py", line 23, in fipy.variables.variable.my_func
Failed example:
    my_func()
Exception raised:
    Traceback (most recent call last):
      File "/Users/guyer/anaconda/envs/fipy/lib/python2.7/doctest.py", line 1315, in __run
        compileflags, 1) in test.globs
      File "<doctest fipy.variables.variable.my_func[0]>", line 1, in <module>
        my_func()
      File "/Users/guyer/Documents/research/FiPy/fipy/fipy/variables/variable.py", line 31, in my_func
        DeprecationWarning
    DeprecationWarning: in my_func


----------------------------------------------------------------------
Ran 347 tests in 18.455s

FAILED (failures=1)

@guyer
Copy link
Member Author

guyer commented Feb 11, 2020

@wd15 Your test case generates an error for me with Python 2.7.15, but not with Python 3.6.7

In Py3k, TestProgram makes it very hard to change DeprecationWarnings
into errors. [TestProgram gives all warnings an action of `default`](https://github.com/python/cpython/blob/master/Lib/unittest/main.py#L84)
which causes [TestRunner to clobber our DeprecationWarning filter](https://github.com/python/cpython/blob/master/Lib/unittest/runner.py#L167)
(passing any other action to TestProgram just causes that action to clobber instead)
@guyer
Copy link
Member Author

guyer commented Feb 13, 2020

@wd15 I managed to get DeprecationWarning to throw on Py3k as well

@guyer guyer mentioned this pull request Feb 14, 2020
@guyer
Copy link
Member Author

guyer commented Feb 14, 2020

@wd15 @tkphd

Copy link
Contributor

@wd15 wd15 left a comment

Choose a reason for hiding this comment

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

Works for me now

@guyer guyer merged commit ea78c12 into usnistgov:master Feb 14, 2020
@guyer guyer deleted the CIs_error_on_DeprecationWarning branch February 14, 2020 23:55
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.

2 participants