Colin-b / pytest_httpx

pytest fixture to mock HTTPX
https://colin-b.github.io/pytest_httpx/
MIT License
358 stars 30 forks source link

Conda cannot install pytest 7 and pytest-httpx 0.20.0 #74

Closed atorres-eqrx closed 2 years ago

atorres-eqrx commented 2 years ago

environment.yml

name: api
channels:
  - conda-forge
dependencies:
  - python==3.9
  - fastapi>=0.73.0
  - uvicorn[standard]>=0.17.4
  - SQLAlchemy>=1.4.31
  - psycopg2>=2.9.3
  - httpx>=0.22.0
  - alembic>=1.7.6
  - SQLAlchemy-Utils>=0.38.2
  - pre-commit>=2.9.3
  - pytest>=7.0.1
  - requests>=2.27.1
  - pytest-httpx>=0.20.0 # conflicts begin when adding this package.
❯ conda env update
Collecting package metadata (repodata.json): done
Solving environment: | 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed                                                                                                                                                                        

UnsatisfiableError: The following specifications were found to be incompatible with a past
explicit spec that is not an explicit spec in this operation (sqlalchemy):

  - alembic[version='>=1.7.6'] -> sqlalchemy[version='>=1.3.0']
  - httpx[version='>=0.22.0']
  - psycopg2[version='>=2.9.3']
  - pytest-httpx[version='>=0.20.0'] -> httpx=0.22
  - pytest-httpx[version='>=0.20.0'] -> pytest=6
  - pytest[version='>=7.0.1']
  - requests[version='>=2.27.1']
  - sqlalchemy-utils[version='>=0.38.2'] -> sqlalchemy[version='>=1.0']
  - sqlalchemy[version='>=1.4.31']

From this CHANGELOG entry it appears as though pytest 7 should be supported.

I'm pretty new to python package management, so I'm not sure if I'm doing something dumb. Also since we're using conda-forge, I checked that artifact repository and I see 0.20 was uploaded 19 days ago, so I'm assuming they have the most up-to-date version.

If I switch from pytest>=7.0.1 => pytest>=6.2.5

❯ conda env update
Collecting package metadata (repodata.json): done
Solving environment: done

Downloading and Extracting Packages
pytest-httpx-0.20.0  | 15 KB     | ################################################################################################################################### | 100% 
pytest-6.2.5         | 434 KB    | ################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

Any pointers would be appreciated.

Thanks!

Colin-b commented 2 years ago

I just tried it, and it works fine with pip on a fresh environment:

python -m pip install pytest-httpx
Collecting pytest-httpx
  Downloading pytest_httpx-0.20.0-py3-none-any.whl (12 kB)
Collecting pytest<8.*,>=6.*
  Downloading pytest-7.0.1-py3-none-any.whl (296 kB)

I don't use conda so I can't say what your issue is. Maybe you already had pytest 6 installed. Can you try with a fresh venv?

Colin-b commented 2 years ago

Also your conda is warning about sqlalchemy.

atorres-eqrx commented 2 years ago

Hi @Colin-b

I took your suggestion and have an update.

brand new environment conda-httpx-pytest-test

environment.yml file

name: conda-httpx-pytest-test
channels:
  - conda-forge
dependencies:
  - python==3.9
  - pytest==7.0.1
  - httpx==0.22.0
  - pytest-httpx==0.20.0

create environment and install dependencies

❯ conda env create --file environment.yml

conflicts

Collecting package metadata (repodata.json): done
Solving environment: / 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed                                                                                                                                                      
Solving environment: | 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed                                                                                                                                                      

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions

Package python conflicts for:
pytest-httpx==0.20.0 -> httpx=0.22 -> python[version='>=3.10,<3.11.0a0|>=3.7,<3.8.0a0|>=3.8,<3.9.0a0|>=3.9,<3.10.0a0|>=3.6,<3.7.0a0']
pytest==7.0.1 -> python[version='>=3.10,<3.11.0a0|>=3.7,<3.8.0a0|>=3.8,<3.9.0a0|>=3.9,<3.10.0a0']
python==3.9
pytest==7.0.1 -> attrs[version='>=19.2.0'] -> python[version='2.7.*|3.4.*|3.5.*|3.6.*|>=2.7|>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*|>=3.6|>=3.6,<3.7.0a0|>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|>=3.5|3.9.*|>=3.7|3.8.*|>=3|3.7.*|3.10.*']
pytest-httpx==0.20.0 -> python[version='>=3.7']

Package pytest conflicts for:
pytest==7.0.1
pytest-httpx==0.20.0 -> pytest=6

Package pypy3.6 conflicts for:
pytest==7.0.1 -> pluggy[version='>=0.12,<2'] -> pypy3.6[version='>=7.3.1|>=7.3.2|>=7.3.3']
httpx==0.22.0 -> certifi -> pypy3.6[version='>=7.3.1|>=7.3.2|>=7.3.3']
pytest-httpx==0.20.0 -> pytest=6 -> pypy3.6[version='>=7.3.1|>=7.3.2|>=7.3.3']

Package python_abi conflicts for:
httpx==0.22.0 -> python_abi[version='3.10.*|3.7.*|3.8.*|3.9.*',build='*_cp310|*_cp37m|*_cp38|*_cp39']
httpx==0.22.0 -> certifi -> python_abi[version='2.7.*|3.6|3.6.*|3.7',build='*_cp36m|*_pypy37_pp73|*_pypy36_pp73|*_cp27m']

Package httpx conflicts for:
pytest-httpx==0.20.0 -> httpx=0.22
httpx==0.22.0

updated environment.yml

name: conda-httpx-pytest-test
channels:
  - conda-forge
dependencies:
  - python==3.9
  - pytest==6.2.5 # downgraded from 7
  - httpx==0.22.0
  - pytest-httpx==0.20.0

create environment and install dependencies

❯ conda env create --file environment.yml
Collecting package metadata (repodata.json): done
Solving environment: done

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate conda-httpx-pytest-test
#
# To deactivate an active environment, use
#
#     $ conda deactivate

This takes sqlalchemy out of the equation.

This part in particular seems suspicious.

Package pytest conflicts for:
pytest==7.0.1
pytest-httpx==0.20.0 -> pytest=6

Update:

Just to make sure this is related to the pytest-httpx package I removed it from the environment.yml file

name: conda-httpx-pytest-test
channels:
  - conda-forge
dependencies:
  - python=3.9
  - pytest==7.0.1 # using pytest 7 again
  - httpx>=0.22.0

Start with a clean environment.

❯ conda env remove -n conda-httpx-pytest-test

Remove all packages in environment ~/miniconda/envs/conda-httpx-pytest-test:

❯ conda env create --file environment.yml  

Collecting package metadata (repodata.json): done
Solving environment: done
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate conda-httpx-pytest-test
#
# To deactivate an active environment, use
#
#     $ conda deactivate
atorres-eqrx commented 2 years ago

Sorry for the stream of consciousness updates, I think I'm getting closer to a lead.

❯ conda search -c conda-forge pytest-httpx==0.20.0 --info
Loading channels: done
pytest-httpx 0.20.0 pyhd8ed1ab_0
--------------------------------
file name   : pytest-httpx-0.20.0-pyhd8ed1ab_0.tar.bz2
name        : pytest-httpx
version     : 0.20.0
build       : pyhd8ed1ab_0
build number: 0
size        : 15 KB
license     : MIT
subdir      : noarch
url         : https://conda.anaconda.org/conda-forge/noarch/pytest-httpx-0.20.0-pyhd8ed1ab_0.tar.bz2
md5         : 96d6c641ea184b0531fc9b6f6879a374
timestamp   : 2022-02-06 05:42:51 UTC
dependencies: 
  - httpx 0.22.*
  - pytest 6.*
  - python >=3.7

I'm having trouble figuring out from where this dependency list is pulled. I don't see python >=3.7 declared in the pytest_httpx repo, but I do see 3.6

Colin-b commented 2 years ago

Indeed python 3.6 was not removed from dependencies yet (should have been though, this is a mistake). But this does not mean that python 3.7 or above are not supported.

Colin-b commented 2 years ago

Your issue seem to be related to the conda package. Can you create it in https://github.com/conda-forge/pytest-httpx-feedstock ? @owenlamont Do you mind having a look at it?

owenlamont commented 2 years ago

Absolutely, if there's incompatible dependencies please do raise that on the feedstock repo and I'll have a look.

Colin-b commented 2 years ago

I think the issue comes from the fact that pytest 6 was pinned in conda package while it was moved to this with latest version: https://github.com/Colin-b/pytest_httpx/blob/4981caab55841a4ccac8d58097e30db15f52448a/setup.py#L43

owenlamont commented 2 years ago

Good callout, I'll resync those dependencies. conda-forge is pretty good at picking up dependencies for some package configurations automatically but I don't think it can parse out dependencies specified in setup.py

Colin-b commented 2 years ago

I need to move to a setup.cfg approach yeah :/

owenlamont commented 2 years ago

I just updated the conda dependencies in this PR. It takes a little while for conda-forge to publish the new package build out... I'll check back tomorrow and try to confirm it is happy to install with pytest 7.

Colin-b commented 2 years ago

Thanks a lot for your support @owenlamont !

owenlamont commented 2 years ago

Sorry responding a bit late but I can confirm conda/mamba seem happy to create environments with pytest 7 and pytest-httpx 0.20