|
| 1 | +"""Test for features module Python 3.10+ compatibility.""" |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | + |
| 6 | +def test_import_features_module(): |
| 7 | + """Test that the features module can be imported without syntax errors. |
| 8 | +
|
| 9 | + This test ensures Python 3.10+ compatibility by verifying that: |
| 10 | + 1. Type annotations with list[], type[], and | syntax work (via __future__ imports) |
| 11 | + 2. No Python 3.11+ exclusive syntax is used (like *unpacking in subscripts) |
| 12 | + """ |
| 13 | + try: |
| 14 | + import eegdash.features |
| 15 | + |
| 16 | + assert eegdash.features is not None |
| 17 | + except SyntaxError as e: |
| 18 | + pytest.fail(f"SyntaxError when importing eegdash.features: {e}") |
| 19 | + except ImportError as e: |
| 20 | + pytest.fail(f"ImportError when importing eegdash.features: {e}") |
| 21 | + |
| 22 | + |
| 23 | +def test_import_features_submodules(): |
| 24 | + """Test that all features submodules can be imported.""" |
| 25 | + submodules = [ |
| 26 | + "eegdash.features.inspect", |
| 27 | + "eegdash.features.extractors", |
| 28 | + "eegdash.features.serialization", |
| 29 | + "eegdash.features.datasets", |
| 30 | + "eegdash.features.decorators", |
| 31 | + "eegdash.features.feature_bank", |
| 32 | + "eegdash.features.feature_bank.complexity", |
| 33 | + "eegdash.features.feature_bank.dimensionality", |
| 34 | + "eegdash.features.feature_bank.signal", |
| 35 | + "eegdash.features.feature_bank.spectral", |
| 36 | + "eegdash.features.feature_bank.connectivity", |
| 37 | + "eegdash.features.feature_bank.csp", |
| 38 | + ] |
| 39 | + |
| 40 | + for module_name in submodules: |
| 41 | + try: |
| 42 | + __import__(module_name) |
| 43 | + except SyntaxError as e: |
| 44 | + pytest.fail(f"SyntaxError when importing {module_name}: {e}") |
| 45 | + except ImportError: |
| 46 | + # Some imports might fail due to missing dependencies, that's ok |
| 47 | + # We only care about SyntaxError |
| 48 | + pass |
| 49 | + |
| 50 | + |
| 51 | +def test_features_basic_functionality(): |
| 52 | + """Test basic features module functionality.""" |
| 53 | + from eegdash.features import ( |
| 54 | + get_all_feature_extractors, |
| 55 | + get_all_feature_kinds, |
| 56 | + get_all_features, |
| 57 | + ) |
| 58 | + |
| 59 | + # These should return lists without errors |
| 60 | + features = get_all_features() |
| 61 | + assert isinstance(features, list) |
| 62 | + |
| 63 | + extractors = get_all_feature_extractors() |
| 64 | + assert isinstance(extractors, list) |
| 65 | + |
| 66 | + kinds = get_all_feature_kinds() |
| 67 | + assert isinstance(kinds, list) |
0 commit comments