Skip to content

Commit a616b91

Browse files
authored
Fix warnings poping up with fixup and pytest (#43109)
* remove license classifier * pytest warnings
1 parent 1802c84 commit a616b91

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,5 @@ markers = [
7272
log_cli = 1
7373
log_cli_level = "WARNING"
7474
asyncio_default_fixture_loop_scope = "function"
75+
# The above pytest-asyncio rule emits unnessecary warnings when it's not installed, so skip it by regex here
76+
filterwarnings = ["ignore:Unknown config option.*asyncio_default_fixture_loop_scope"]

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,6 @@ def run(self):
407407
"Intended Audience :: Developers",
408408
"Intended Audience :: Education",
409409
"Intended Audience :: Science/Research",
410-
"License :: OSI Approved :: Apache Software License",
411410
"Operating System :: OS Independent",
412411
"Programming Language :: Python :: 3",
413412
"Programming Language :: Python :: 3.10",

src/transformers/testing_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
is_pyctcdecode_available,
132132
is_pytesseract_available,
133133
is_pytest_available,
134+
is_pytest_order_available,
134135
is_pytorch_quantization_available,
135136
is_quark_available,
136137
is_qutlass_available,
@@ -2670,9 +2671,13 @@ def run_first(test_case):
26702671
single process at a time. So we make sure all tests that run in a subprocess are launched first, to avoid device
26712672
allocation conflicts.
26722673
"""
2673-
import pytest
2674+
# Without this check, we get unwanted warnings when it's not installed
2675+
if is_pytest_order_available():
2676+
import pytest
26742677

2675-
return pytest.mark.order(1)(test_case)
2678+
return pytest.mark.order(1)(test_case)
2679+
else:
2680+
return test_case
26762681

26772682

26782683
def run_test_in_subprocess(test_case, target_func, inputs=None, timeout=None):

src/transformers/utils/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
is_pyctcdecode_available,
186186
is_pytesseract_available,
187187
is_pytest_available,
188+
is_pytest_order_available,
188189
is_pytorch_quantization_available,
189190
is_quanto_greater,
190191
is_quark_available,

src/transformers/utils/import_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,11 @@ def is_pytest_available() -> bool:
10841084
return _is_package_available("pytest")
10851085

10861086

1087+
@lru_cache
1088+
def is_pytest_order_available() -> bool:
1089+
return is_pytest_available() and _is_package_available("pytest_order")
1090+
1091+
10871092
@lru_cache
10881093
def is_spacy_available() -> bool:
10891094
return _is_package_available("spacy")

0 commit comments

Comments
 (0)