Skip to content

Strange warning potentially related with the way pytest imports modules in conftest.py. #9072

Open
@okhoma

Description

@okhoma
  1. Create new environment:
conda create -p .\env_minimal python pytest numpy netCDF4
  1. Create test_netcdf4.py with a single line of code:
import netCDF4
  1. Create conftest.py with a single line of code:
import numpy
  1. Run pytest:
pytest test_netcdf4.py
  1. Warning is displayed:
========================================== test session starts ==========================================
platform win32 -- Python 3.9.6, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: E:\LDC-RR-Jenkins-Docker
collected 0 items                                                                                        

=========================================== warnings summary ============================================
<frozen importlib._bootstrap>:228
  <frozen importlib._bootstrap>:228: RuntimeWarning: numpy.ndarray size changed, may indicate binary incompatibility. Expected 16 from C header, got 88 from PyObject

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================== 1 warning in 1.28s ===========================================
  1. Moving both import statements into either test_netcdf4.py or conftest.py or removing import numpy from conftest.py no longer produces warning
========================================== test session starts ==========================================
platform win32 -- Python 3.9.6, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: E:\LDC-RR-Jenkins-Docker
collected 0 items                                                                                        

========================================= no tests ran in 0.46s =========================================

--
conda list output:

# Name                    Version                   Build  Channel
atomicwrites              1.4.0                      py_0
attrs                     21.2.0             pyhd3eb1b0_0
blas                      1.0                         mkl
ca-certificates           2021.7.5             haa95532_1
certifi                   2021.5.30        py39haa95532_0
cftime                    1.5.0            py39h080aedc_0
colorama                  0.4.4              pyhd3eb1b0_0
curl                      7.78.0               h86230a5_0
hdf4                      4.2.13               h712560f_2
hdf5                      1.10.6               h7ebc959_0
icc_rt                    2019.0.0             h0cc432a_1
iniconfig                 1.1.1              pyhd3eb1b0_0
intel-openmp              2021.3.0          haa95532_3372
jpeg                      9b                   hb83a4c4_2
krb5                      1.19.2               h5b6d351_0
libcurl                   7.78.0               h86230a5_0
libnetcdf                 4.6.1                hf59b723_4
libssh2                   1.9.0                h7a1dbc1_1
mkl                       2021.3.0           haa95532_524
mkl-service               2.4.0            py39h2bbff1b_0
mkl_fft                   1.3.0            py39h277e83a_2
mkl_random                1.2.2            py39hf11a4ad_0
more-itertools            8.8.0              pyhd3eb1b0_0
netcdf4                   1.5.7            py39hb76ebac_0
numpy                     1.20.3           py39ha4e8547_0
numpy-base                1.20.3           py39hc2deb75_0
openssl                   1.1.1l               h2bbff1b_0
packaging                 21.0               pyhd3eb1b0_0
pip                       21.2.4           py38haa95532_0
pluggy                    0.13.1           py39haa95532_0
py                        1.10.0             pyhd3eb1b0_0
pyparsing                 2.4.7              pyhd3eb1b0_0
pytest                    6.2.4            py39haa95532_2
python                    3.9.6                h6244533_1
setuptools                52.0.0           py39haa95532_0
six                       1.16.0             pyhd3eb1b0_0
sqlite                    3.36.0               h2bbff1b_0
toml                      0.10.2             pyhd3eb1b0_0
tzdata                    2021a                h5d7bf9c_0
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wheel                     0.37.0             pyhd3eb1b0_0
wincertstore              0.2              py39h2bbff1b_0
zlib                      1.2.11               h62dcd97_4

Reproduced on Windows and on Mac OS X.

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: warningsrelated to the warnings builtin plugintopic: configrelated to config handling, argument parsing and config file

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions