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

Replace distutils.version with packaging.version.path #35

Open
pquentin opened this issue Nov 12, 2021 · 8 comments
Open

Replace distutils.version with packaging.version.path #35

pquentin opened this issue Nov 12, 2021 · 8 comments

Comments

@pquentin
Copy link

Using the pytest plugin on 3.11 (but 3.10 too) gives the following warning:

/home/runner/work/urllib3/urllib3/.nox/test-3-11/lib/python3.11/site-packages/pytest_freezegun.py:5: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.version import LooseVersion

One option to fix this is to use packaging.version.path as done by @hugovk here: https://github.com/python-pillow/Pillow/pull/4797/files

Initial reported in spulec/freezegun#428 by mistake

@hugovk
Copy link

hugovk commented Nov 12, 2021

Please see PR #36.

@psi29a
Copy link

psi29a commented Feb 4, 2022

Following...

jaraco added a commit to jaraco/tempora that referenced this issue Feb 12, 2022
lyz-code added a commit to lyz-code/blue-book that referenced this issue Feb 17, 2022
[Roguelynn tutorial](https://www.roguelynn.com/words/asyncio-we-did-it-wrong/)

feat(feedparser#issues): Add issue when using `updated_parser`

[Deprecation warning when using `updated_parsed`](kurtmckee/feedparser#151)

fix(pytest): update the tmpdir_factory type hints

You should now use `TempPathFactory` instead of `TempdirFactory`

fix(pytest#global-usage): Use `pytest-freezegun` globally

[Most of the tests](https://medium.com/@boxed/flaky-tests-part-3-freeze-the-world-e4929a0da00e)
work with frozen time, so it's better to freeze it by default and unfreeze it on
the ones that actually need time to move.

To do that set in your `tests/conftest.py` a globally used fixture:

```python
if TYPE_CHECKING:
    from freezegun.api import FrozenDateTimeFactory

@pytest.fixture(autouse=True)
def frozen_time() -> Generator['FrozenDateTimeFactory', None, None]:
    """Freeze all tests time"""
    with freezegun.freeze_time() as freeze:
        yield freeze
```

feat(pytest): Ignore a warning of a specific package

In the `pyproject.toml`

```toml
filterwarnings = [
  "error",
  # Until ktosiek/pytest-freezegun#35 is merged
  "ignore::DeprecationWarning:pytest_freezegun.*"
]
```

feat(python_snippets#How to raise a warning): How to raise a warning

Warning messages are typically issued in situations where it is useful to alert
the user of some condition in a program, where that condition (normally) doesn’t
warrant raising an exception and terminating the program. For example, one might
want to issue a warning when a program uses an obsolete module.

```python
import warnings

def f():
    warnings.warn('Message', DeprecationWarning)
```

To test the function with pytest you can use
[`pytest.warns`](https://docs.pytest.org/en/stable/how-to/capture-warnings.html#warns):

```python
import warnings
import pytest

def test_warning():
    with pytest.warns(UserWarning, match='my warning'):
        warnings.warn("my warning", UserWarning)
```

feat(python_snippets#Parse XML file with beautifulsoup): Parse XML file with beautifulsoup

You need both `beautifulsoup4` and `lxml`:

```python
bs = BeautifulSoup(requests.get(url), "lxml")
```

feat(python_snippets#Get a traceback from an exception): Get a traceback from an exception

```python
import traceback

traceback_str = ''.join(traceback.format_tb(e.__traceback__))
```

feat(flakeheaven): Deprecate flakehell in favour of flakeheaven

It's a fork maintained by the community, instead of an absent code
dictator.

feat(fastapi#Resolve the 307 error): Resolve the 307 error

Probably you've introduced an ending `/` to the endpoint, so instead of asking
for `/my/endpoint` you tried to do `/my/endpoint/`.

feat(pdm): Version overriding now supports constrains

Before you had to pin specific versions, which is not maintainable, now
you can use constrains

```toml
[tool.pdm.overrides]
asgiref = ">=3.2.10"
```

feat(pdm#Show outdated packages): Show outdated packages

```bash
pdm update --dry-run --unconstrained
```

fix(pydantic_factories): correct the type hints of the factory

Use `Any`

```python
class PersonFactory(ModelFactory[Any]):
    ...
```

feat(pydantic_factories#issues): Track issue when using with
`pytest-freezegun`

[Use pydantic-factories with pytest-freezegun](litestar-org/polyfactory#29)

feat(python#install): Install a specific version

* Install dependencies
    ```bash
    sudo apt install wget software-properties-common build-essential libnss3-dev zlib1g-dev libgdbm-dev libncurses5-dev libssl-dev libffi-dev libreadline-dev libsqlite3-dev libbz2-dev
    ```

* Select the version in https://www.python.org/ftp/python/ and download it
    ```bash
    wget https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tgz
    cd Python-3.9.2/
    ./configure --enable-optimizations
    sudo make altinstall
    ```

perf(regicide): fix typos

fix(wallabag): Remove Wallabag rss issue as it's solved

Rss feeds linked to the wallabag instance instead to the referenced article, not anymore.
@julian-r
Copy link

I would love to see this merged

@hugovk
Copy link

hugovk commented Apr 8, 2022

Please see PR #38 as an alternative.

clrpackages pushed a commit to clearlinux-pkgs/pypi-tempora that referenced this issue Jul 19, 2022
…ion 5.0.2

Anderson Bravalheri (2):
      Ignore flake8/black warnings with pytest 7.0.1 (jaraco/skeleton#58)
      Update Github actions to v3 (#62)

Hugo van Kemenade (1):
      Update base URL for PEPs (#61)

Jason R. Coombs (27):
      Add Tidelift template
      Rely on alabaster theme to support sidebar rendering.
      Use nicer, simpler phrasing
      Add support for automatic publishing of release notes
      Use technique for environment passing matching that found in jaraco/skeleton
      Move Tidelift token into Travis configuration
      Update badge URL
      Add funding reference to project
      List sidebars to avoid errors looking for template 't'
      Rebrand to 'For Enterprise'
      Add a 'For Enterprise' section to the README
      Include token passthrough for azure pipelines publish stage.
      Move Tidelift release note publishing to Github Actions.
      Tidelift no longer requires or expects publishing release notes.
      Remove Tidelift from main.yml, no longer needed
      Implement tidelift banner using a Sphinx directive implemented by jaraco.tidelift.
      Add exclusions for pytest 7 deprecations in plugins. Fixes jaraco/skeleton#57.
      Use the parent category PytestDeprecationWarning, which is available on older pytest versions. Fixes jaraco/skeleton#57.
      Bump pytest-mypy and remove workaround for realpython/pytest-mypy#131.
      Require jaraco.packaging 9 adding compatibility for projects with no setup.py file.
      Suppress DeprecationWarning. Ref ktosiek/pytest-freezegun#35.
      Ran pre-commit autoupdate
      Add Python 3.11 into the matrix using workaround from actions/setup-python#213. Drop 3.9 from matrix for efficiency.
      Prefer spaces for rst. Fixes jaraco/skeleton#64.
      Honor PEP 518 with pytest-enabler.
      Ran pre-commit autoupdate
      Update changelog.

Sviatoslav Sydorenko (1):
      Inject check job into CI workflow as ultimate flag (#55)

wim glenn (1):
      exclude build env from cov reporting (#60)
wimglenn added a commit to wimglenn/pytest-freezegun that referenced this issue Oct 4, 2022
@jaraco
Copy link

jaraco commented May 11, 2023

This error is causing test failures on Python 3.12.

@knaou
Copy link

knaou commented Oct 29, 2023

+1

@jaraco
Copy link

jaraco commented Oct 29, 2023

Please see #44 - this package is abandoned and should not be used. Use pytest-freezer instead.

@Alexander-Serov
Copy link

Placing a link to pytest-freezer for easier navigation: https://github.com/pytest-dev/pytest-freezer

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