Skip to content

astropy.test() should be able to test docstrings #8153

Closed as not planned
Closed as not planned

Description

@pllim

My conclusion from #8146 is that astropy.test() (testing installed code) is not running the exact same set of tests under the same settings as python setup.py test (testing full source code). Do we care? If so, what can we do about it (probably would involve refactoring the test runner)?

Activity

  1. drdavella commented on Nov 18, 2018

    @drdavella
    Contributor

    This is not at all surprising. I'm not sure if we care or not. If possible can you put a diff here?

    Friends, I beg of you, let's please consider axing the test runner entirely.

  2. pllim commented on Nov 18, 2018

    @pllim
    MemberAuthor

    @drdavella , are you saying getting rid of astropy.test() entirely? Or can astropy.test() machinery be done in a different way (tox?)?

  3. bsipocz commented on Nov 18, 2018

    @bsipocz
    Member

    I suppose the difference is coming mainly from the fact that the narrative docs is not available in the installed version?

  4. drdavella commented on Nov 18, 2018

    @drdavella
    Contributor

    @bsipocz that's almost certainly true, but I wouldn't be entirely surprised to see other differences as well.

    @pllim it's fine to keep astropy.test() (although if we were designing things from the ground up I might reconsider), but it could definitely call either pytest.main or tox.main directly.

  5. bsipocz commented on Nov 18, 2018

    @bsipocz
    Member

    I'm against in any way of removing astropy.test(). That is a super useful and easy way to test user installations, no tox or else can make it cleaner and easier.

  6. astrofrog commented on Nov 19, 2018

    @astrofrog
    Member

    I'm with @bsipocz that astropy.test() has been really useful in the past, otherwise there is no way to test user installations (for example from conda or other package managers)

    There's also no way for astropy.test to run the rst docs tests, and I think that's fine - astropy.test() should just be assumed to run a subset of the tests.

  7. pllim commented on Nov 19, 2018

    @pllim
    MemberAuthor

    In addition of not running doctest, it also is not respecting settings in setup.cfg. Not sure if it is a feature or a bug. (I was going to give examples but I have to get around #8148 first. 🌀

  8. bsipocz commented on Nov 19, 2018

    @bsipocz
    Member

    @pllim - No wonder, setup.cfg is not available in the installed version. If we need the settings from it, it has to be a hack that propagates them to somewhere else, e.g. astropy.cfg etc.

  9. pllim commented on Nov 19, 2018

    @pllim
    MemberAuthor

    @drdavella , as requested...

    Log from python setup.py test --remote-data:
    zlog_source.txt
    11889 passed, 107 skipped, 111 xfailed in 337.78 seconds

    Log from astropy.test(remote_data=True):
    zlog_install.txt
    11548 passed, 103 skipped, 109 xfailed, 2 xpassed, 3136 warnings in 285.30 seconds

    IMHO the most perplexing is the 2 xpassed tests; i.e, they failed when tested from source but passed when tested from installation.

  10. bsipocz commented on Mar 19, 2019

    @bsipocz
    Member

    I have much bigger differences locally, than your numbers (~1000). Of those are ~390 are doctests.
    Yet a fraction of those doctests should be tested as they are docstrings in the source code that is also available in an install.

    I'm not yet sure what the other ~600 tests are.

    Todo item here: make it possible for astropy.test() to pick up docstrings for testing.

  11. changed the title [-]TST: astropy.test() not testing the same stuff as setup.py test[/-] [+]astropy.test() should be able to test docstrings[/+] on Mar 19, 2019
  12. bsipocz commented on Mar 19, 2019

    @bsipocz
    Member

    I suspect some of the pytest parametrization messes up astropy.test(). E.g. running all tests but then focusing only on the constants one:

    • with python setup.py test -V --remote-data
    astropy/constants/__init__.py::astropy.constants PASSED                                                          [  0%]
    astropy/constants/tests/test_constant.py::test_c PASSED                                                          [  0%]
    astropy/constants/tests/test_constant.py::test_h PASSED                                                          [  0%]
    astropy/constants/tests/test_constant.py::test_e PASSED                                                          [  0%]
    astropy/constants/tests/test_constant.py::test_g0 PASSED                                                         [  0%]
    astropy/constants/tests/test_constant.py::test_b_wien PASSED                                                     [  0%]
    astropy/constants/tests/test_constant.py::test_unit PASSED                                                       [  0%]
    astropy/constants/tests/test_constant.py::test_copy PASSED                                                       [  0%]
    astropy/constants/tests/test_constant.py::test_view PASSED                                                       [  0%]
    astropy/constants/tests/test_pickle.py::test_new_constant[0-original0-True] xfail                                [  0%]
    astropy/constants/tests/test_pickle.py::test_new_constant[0-original1-True] xfail                                [  0%]
    astropy/constants/tests/test_pickle.py::test_new_constant[0-original2-True] xfail                                [  0%]
    astropy/constants/tests/test_pickle.py::test_new_constant[1-original0-True] xfail                                [  0%]
    astropy/constants/tests/test_pickle.py::test_new_constant[1-original1-True] xfail                                [  0%]
    astropy/constants/tests/test_pickle.py::test_new_constant[1-original2-True] xfail                                [  0%]
    astropy/constants/tests/test_pickle.py::test_new_constant[-1-original0-True] xfail                               [  0%]
    astropy/constants/tests/test_pickle.py::test_new_constant[-1-original1-True] xfail                               [  0%]
    astropy/constants/tests/test_pickle.py::test_new_constant[-1-original2-True] xfail                               [  0%]
    astropy/constants/tests/test_prior_version.py::test_c PASSED                                                     [  0%]
    astropy/constants/tests/test_prior_version.py::test_h PASSED                                                     [  0%]
    astropy/constants/tests/test_prior_version.py::test_e PASSED                                                     [  0%]
    astropy/constants/tests/test_prior_version.py::test_g0 PASSED                                                    [  0%]
    astropy/constants/tests/test_prior_version.py::test_b_wien PASSED                                                [  0%]
    astropy/constants/tests/test_prior_version.py::test_unit PASSED                                                  [  0%]
    astropy/constants/tests/test_prior_version.py::test_copy PASSED                                                  [  0%]
    astropy/constants/tests/test_prior_version.py::test_view PASSED                                                  [  0%]
    astropy/constants/tests/test_prior_version.py::test_context_manager PASSED                                       [  0%]
    

    in ipython with astropy.test(remote_data='all', verbose=True)

    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_c PASSED                                                                           [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_h PASSED                                                                           [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_e PASSED                                                                           [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_g0 PASSED                                                                          [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_b_wien PASSED                                                                      [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_unit PASSED                                                                        [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_copy PASSED                                                                        [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_view PASSED                                                                        [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[0-original0-xfail0] SKIPPED                                             [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[1-original0-xfail0] SKIPPED                                             [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[-1-original0-xfail0] SKIPPED                                            [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_c PASSED                                                                      [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_h PASSED                                                                      [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_e PASSED                                                                      [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_g0 PASSED                                                                     [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_b_wien PASSED                                                                 [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_unit PASSED                                                                   [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_copy PASSED                                                                   [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_view PASSED                                                                   [  0%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_context_manager PASSED                                                        [  0%]
    
  13. bsipocz commented on Mar 19, 2019

    @bsipocz
    Member

    However, starting a new ipython, and running just the constants tests, twice, I don't get the same number. And this is the point where I give up...:

    ===================================================================================== test session starts ======================================================================================
    platform darwin -- Python 3.7.2, pytest-4.1.1, py-1.7.0, pluggy-0.8.1 -- /Users/bsipocz/miniconda/envs/mlbook_code/bin/python
    cachedir: .pytest_cache
    
    Running tests with Astropy version 3.1.2.
    Running tests in miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants.
    
    Date: 2019-03-18T20:37:05
    
    Platform: Darwin-17.7.0-x86_64-i386-64bit
    
    Executable: /Users/bsipocz/miniconda/envs/mlbook_code/bin/python
    
    Full Python Version: 
    3.7.2 (default, Dec 29 2018, 00:00:04) 
    [Clang 4.0.1 (tags/RELEASE_401/final)]
    
    encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8
    byteorder: little
    float info: dig: 15, mant_dig: 15
    
    Numpy: 1.16.0
    Scipy: 1.2.0
    Matplotlib: 3.0.2
    h5py: 2.9.0
    Pandas: 0.24.0
    Cython: not available
    Scikit-image: not available
    astropy_helpers: 3.1.1
    Using Astropy options: remote_data: any.
    
    rootdir: /Users/bsipocz, inifile:
    plugins: remotedata-0.3.1, openfiles-0.3.2, cov-2.6.1, arraydiff-0.3, doctestplus-0.3.0.dev0
    collected 26 items                                                                                                                                                                             
    
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_c PASSED                                                                           [  3%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_h PASSED                                                                           [  7%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_e PASSED                                                                           [ 11%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_g0 PASSED                                                                          [ 15%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_b_wien PASSED                                                                      [ 19%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_unit PASSED                                                                        [ 23%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_copy PASSED                                                                        [ 26%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_view PASSED                                                                        [ 30%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[0-original0-True] xfail                                                 [ 34%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[0-original1-True] xfail                                                 [ 38%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[0-original2-True] xfail                                                 [ 42%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[1-original0-True] xfail                                                 [ 46%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[1-original1-True] xfail                                                 [ 50%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[1-original2-True] xfail                                                 [ 53%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[-1-original0-True] xfail                                                [ 57%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[-1-original1-True] xfail                                                [ 61%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[-1-original2-True] xfail                                                [ 65%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_c PASSED                                                                      [ 69%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_h PASSED                                                                      [ 73%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_e PASSED                                                                      [ 76%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_g0 PASSED                                                                     [ 80%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_b_wien PASSED                                                                 [ 84%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_unit PASSED                                                                   [ 88%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_copy PASSED                                                                   [ 92%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_view PASSED                                                                   [ 96%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_context_manager PASSED                                                        [100%]
    
    ============================================================================= 17 passed, 9 xfailed in 0.66 seconds =============================================================================
    Out[3]: 0
    
    In [4]: astropy.test(remote_data='all', verbose=True, package='constants')                                                                                                                      
    ===================================================================================== test session starts ======================================================================================
    platform darwin -- Python 3.7.2, pytest-4.1.1, py-1.7.0, pluggy-0.8.1 -- /Users/bsipocz/miniconda/envs/mlbook_code/bin/python
    cachedir: .pytest_cache
    
    Running tests with Astropy version 3.1.2.
    Running tests in miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants.
    
    Date: 2019-03-18T20:37:16
    
    Platform: Darwin-17.7.0-x86_64-i386-64bit
    
    Executable: /Users/bsipocz/miniconda/envs/mlbook_code/bin/python
    
    Full Python Version: 
    3.7.2 (default, Dec 29 2018, 00:00:04) 
    [Clang 4.0.1 (tags/RELEASE_401/final)]
    
    encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8
    byteorder: little
    float info: dig: 15, mant_dig: 15
    
    Numpy: 1.16.0
    Scipy: 1.2.0
    Matplotlib: 3.0.2
    h5py: 2.9.0
    Pandas: 0.24.0
    Cython: not available
    Scikit-image: not available
    astropy_helpers: 3.1.1
    Using Astropy options: remote_data: any.
    
    rootdir: /Users/bsipocz, inifile:
    plugins: remotedata-0.3.1, openfiles-0.3.2, cov-2.6.1, arraydiff-0.3, doctestplus-0.3.0.dev0
    collected 20 items                                                                                                                                                                             
    
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_c PASSED                                                                           [  5%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_h PASSED                                                                           [ 10%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_e PASSED                                                                           [ 15%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_g0 PASSED                                                                          [ 20%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_b_wien PASSED                                                                      [ 25%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_unit PASSED                                                                        [ 30%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_copy PASSED                                                                        [ 35%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_constant.py::test_view PASSED                                                                        [ 40%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[0-original0-xfail0] SKIPPED                                             [ 45%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[1-original0-xfail0] SKIPPED                                             [ 50%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_pickle.py::test_new_constant[-1-original0-xfail0] SKIPPED                                            [ 55%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_c PASSED                                                                      [ 60%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_h PASSED                                                                      [ 65%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_e PASSED                                                                      [ 70%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_g0 PASSED                                                                     [ 75%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_b_wien PASSED                                                                 [ 80%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_unit PASSED                                                                   [ 85%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_copy PASSED                                                                   [ 90%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_view PASSED                                                                   [ 95%]
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/astropy/constants/tests/test_prior_version.py::test_context_manager PASSED                                                        [100%]
    
    ======================================================================================= warnings summary =======================================================================================
    miniconda/envs/mlbook_code/lib/python3.7/site-packages/_pytest/config/__init__.py:730
      /Users/bsipocz/miniconda/envs/mlbook_code/lib/python3.7/site-packages/_pytest/config/__init__.py:730: PytestWarning: Module already imported so cannot be rewritten: pytest_remotedata
        self._mark_plugins_for_rewrite(hook)
      /Users/bsipocz/miniconda/envs/mlbook_code/lib/python3.7/site-packages/_pytest/config/__init__.py:730: PytestWarning: Module already imported so cannot be rewritten: pytest_openfiles
        self._mark_plugins_for_rewrite(hook)
      /Users/bsipocz/miniconda/envs/mlbook_code/lib/python3.7/site-packages/_pytest/config/__init__.py:730: PytestWarning: Module already imported so cannot be rewritten: pytest_arraydiff
        self._mark_plugins_for_rewrite(hook)
      /Users/bsipocz/miniconda/envs/mlbook_code/lib/python3.7/site-packages/_pytest/config/__init__.py:730: PytestWarning: Module already imported so cannot be rewritten: pytest_doctestplus
        self._mark_plugins_for_rewrite(hook)
    
    -- Docs: https://docs.pytest.org/en/latest/warnings.html
    ======================================================================= 17 passed, 3 skipped, 4 warnings in 0.08 seconds =======================================================================
    
  14. pllim commented on Mar 19, 2019

    @pllim
    MemberAuthor

    There was a separate conversation on Slack (@Cadair, @astrofrog, and @drdavella) saying something about moving tests outside of distributed package. If that is going to happen, then astropy.test() would disappear and this would become a non-issue...

  15. bsipocz commented on Mar 19, 2019

    @bsipocz
    Member

    yes, I know @drdavella and @Cadair would like that happen, but the rest of us keep saying that astropy.test() is way to valuable to see user issues that it would be a waste to get rid of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions