Skip to content

Commit bc9dc84

Browse files
authored
Quiesce pytest warnings (#916)
* Skip doctest of deprecated format_number * Don't return from test_compatible_classes_in_global_and_localedata * Renovate conftest (and require pytest 6+)
1 parent 52b83d3 commit bc9dc84

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

babel/numbers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,9 @@ def get_group_symbol(locale=LC_NUMERIC):
338338
def format_number(number, locale=LC_NUMERIC):
339339
u"""Return the given number formatted for a specific locale.
340340
341-
>>> format_number(1099, locale='en_US')
341+
>>> format_number(1099, locale='en_US') # doctest: +SKIP
342342
u'1,099'
343-
>>> format_number(1099, locale='de_DE')
343+
>>> format_number(1099, locale='de_DE') # doctest: +SKIP
344344
u'1.099'
345345
346346
.. deprecated:: 2.6.0

conftest.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1+
from pathlib import Path
2+
13
from _pytest.doctest import DoctestModule
2-
from py.path import local
34

45
collect_ignore = ['tests/messages/data', 'setup.py']
5-
babel_path = local(__file__).dirpath().join('babel')
6+
babel_path = Path(__file__).parent / 'babel'
7+
8+
9+
# Via the stdlib implementation of Path.is_relative_to in Python 3.9
10+
def _is_relative(p1: Path, p2: Path) -> bool:
11+
try:
12+
p1.relative_to(p2)
13+
return True
14+
except ValueError:
15+
return False
616

717

8-
def pytest_collect_file(path, parent):
9-
if babel_path.common(path) == babel_path:
10-
if path.ext == ".py":
11-
# TODO: remove check when dropping support for old Pytest
12-
if hasattr(DoctestModule, "from_parent"):
13-
return DoctestModule.from_parent(parent, fspath=path)
14-
return DoctestModule(path, parent)
18+
def pytest_collect_file(file_path: Path, parent):
19+
if _is_relative(file_path, babel_path) and file_path.suffix == '.py':
20+
return DoctestModule.from_parent(parent, path=file_path)

tests/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def find_class(self, module, name):
313313
(module, name))
314314

315315
with open(filename, 'rb') as f:
316-
return Unpickler(f).load()
316+
assert Unpickler(f).load()
317317

318318

319319
def test_issue_601_no_language_name_but_has_variant():

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ envlist =
55

66
[testenv]
77
deps =
8-
pytest
8+
pytest>=6.0
99
pytest-cov
1010
freezegun==0.3.12
1111
backports.zoneinfo;python_version<"3.9"

0 commit comments

Comments
 (0)