ryankert01 commented on code in PR #832: URL: https://github.com/apache/mahout/pull/832#discussion_r2695094108
########## conftest.py: ########## @@ -0,0 +1,98 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Root pytest configuration for Apache Mahout. + +This module provides: +- Custom pytest markers (gpu, slow) +- Auto-skip logic for QDP tests when the native extension is not built +- Shared fixtures for QDP availability checking + +QDP tests are automatically skipped if the _qdp extension is not available, +allowing contributors without CUDA to run the qumat test suite. +""" + +import importlib.util + +import pytest + +# Check if QDP extension is available at module load time +_QDP_SPEC = importlib.util.find_spec("_qdp") +_QDP_AVAILABLE = _QDP_SPEC is not None +_QDP_IMPORT_ERROR = None if _QDP_AVAILABLE else "No module named '_qdp'" + + +def pytest_configure(config): + """Register custom pytest markers.""" + config.addinivalue_line( + "markers", "gpu: marks tests as requiring GPU and _qdp extension" + ) + config.addinivalue_line("markers", "slow: marks tests as slow running") + + +def pytest_collection_modifyitems(config, items): + """Auto-skip GPU/QDP tests if the _qdp extension is not available.""" + if _QDP_AVAILABLE: + return + + skip_marker = pytest.mark.skip( + reason=f"QDP extension not available: {_QDP_IMPORT_ERROR}. " + "Build with: cd qdp/qdp-python && maturin develop" + ) + + for item in items: + # Skip tests explicitly marked with @pytest.mark.gpu + if "gpu" in item.keywords: + item.add_marker(skip_marker) + + # Skip all tests in testing/qdp/ directory + fspath_str = str(item.fspath) + if "testing/qdp" in fspath_str or "testing\\qdp" in fspath_str: Review Comment: Thanks for reading the issue! Exactly, that’s why we change to testing folder! To align with original mahout design. You can advice the target design at the same issue. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
