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

Quiesce pytest warnings #916

Merged
merged 3 commits into from Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions babel/numbers.py
Expand Up @@ -338,9 +338,9 @@ def get_group_symbol(locale=LC_NUMERIC):
def format_number(number, locale=LC_NUMERIC):
u"""Return the given number formatted for a specific locale.

>>> format_number(1099, locale='en_US')
>>> format_number(1099, locale='en_US') # doctest: +SKIP
u'1,099'
>>> format_number(1099, locale='de_DE')
>>> format_number(1099, locale='de_DE') # doctest: +SKIP
u'1.099'

.. deprecated:: 2.6.0
Expand Down
24 changes: 15 additions & 9 deletions conftest.py
@@ -1,14 +1,20 @@
from pathlib import Path

from _pytest.doctest import DoctestModule
from py.path import local

collect_ignore = ['tests/messages/data', 'setup.py']
babel_path = local(__file__).dirpath().join('babel')
babel_path = Path(__file__).parent / 'babel'


# Via the stdlib implementation of Path.is_relative_to in Python 3.9
def _is_relative(p1: Path, p2: Path) -> bool:
try:
p1.relative_to(p2)
return True
except ValueError:
return False


def pytest_collect_file(path, parent):
if babel_path.common(path) == babel_path:
if path.ext == ".py":
# TODO: remove check when dropping support for old Pytest
if hasattr(DoctestModule, "from_parent"):
return DoctestModule.from_parent(parent, fspath=path)
return DoctestModule(path, parent)
def pytest_collect_file(file_path: Path, parent):
if _is_relative(file_path, babel_path) and file_path.suffix == '.py':
return DoctestModule.from_parent(parent, path=file_path)
2 changes: 1 addition & 1 deletion tests/test_core.py
Expand Up @@ -313,7 +313,7 @@ def find_class(self, module, name):
(module, name))

with open(filename, 'rb') as f:
return Unpickler(f).load()
assert Unpickler(f).load()


def test_issue_601_no_language_name_but_has_variant():
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Expand Up @@ -5,7 +5,7 @@ envlist =

[testenv]
deps =
pytest
pytest>=6.0
pytest-cov
freezegun==0.3.12
backports.zoneinfo;python_version<"3.9"
Expand Down