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

MNT: Add explicit support for Python 3.10 on windows #3706

Merged
merged 2 commits into from
Jan 19, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/workflows/build-test-pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ jobs:
python-version: 3.7
dependencies: minimal
tests-type: unit
# temporary: Python 3.10 is not available on conda, so we pin this job to Python 3.9
- os: windows-latest
python-version: '3.9'
exclude:
- os: windows-latest
python-version: '3.10'

runs-on: ${{ matrix.os }}
steps:
Expand Down
31 changes: 19 additions & 12 deletions yt/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import matplotlib
import numpy as np
import pytest
from more_itertools import always_iterable
from numpy.random import RandomState
from unyt.exceptions import UnitOperationError
Expand Down Expand Up @@ -856,6 +857,21 @@ def expand_keywords(keywords, full=False):
return list_of_kwarg_dicts


def skip_case(*, reason: str):
"""
An adapter test skipping function that should work with both test runners
(nosetest or pytest) and with any Python version.
"""
if sys.version_info >= (3, 10):
# nose isn't compatible with Python 3.10 so we can't import it here
pytest.skip(reason)
else:
# pytest.skip() isn't recognized by nosetest (but nose.SkipTest works in pytest !)
from nose import SkipTest

raise SkipTest(reason)


def requires_module(module):
"""
Decorator that takes a module name as an argument and tries to import it.
Expand All @@ -864,12 +880,11 @@ def requires_module(module):
being imported will not fail if the module is not installed on the testing
platform.
"""
from nose import SkipTest

def ffalse(func):
@functools.wraps(func)
def false_wrapper(*args, **kwargs):
raise SkipTest
skip_case(reason=f"Missing required module {module}")

return false_wrapper

Expand Down Expand Up @@ -901,8 +916,6 @@ def requires_module_pytest(*module_names):

So that it can be later renamed to `requires_module`.
"""
import pytest

from yt.utilities import on_demand_imports as odi

def deco(func):
Expand Down Expand Up @@ -930,16 +943,14 @@ def inner_func(*args, **kwargs):


def requires_file(req_file):
from nose import SkipTest

path = ytcfg.get("yt", "test_data_dir")

def ffalse(func):
@functools.wraps(func)
def false_wrapper(*args, **kwargs):
if ytcfg.get("yt", "internals", "strict_requires"):
raise FileNotFoundError(req_file)
raise SkipTest
skip_case(reason=f"Missing required file {req_file}")

return false_wrapper

Expand Down Expand Up @@ -1339,7 +1350,6 @@ def requires_backend(backend):
Decorated function or null function

"""
import pytest

def ffalse(func):
# returning a lambda : None causes an error when using pytest. Having
Expand All @@ -1350,8 +1360,7 @@ def ffalse(func):
# exception in the xfail case for that test
def skip(*args, **kwargs):
msg = f"`{backend}` backend not in use, skipping: `{func.__name__}`"
print(msg, file=sys.stderr)
pytest.skip(msg)
skip_case(reason=msg)

if ytcfg.get("yt", "internals", "within_pytest"):
return skip
Expand All @@ -1367,8 +1376,6 @@ def ftrue(func):


def requires_external_executable(*names):
import pytest

def deco(func):
missing = []
for name in names:
Expand Down