You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
π¨++ New Plug-in Integrated ++ π¨
- Stomatal Conductance plug-in integrated with PyHelios
- Made some updates to testing infrastructure to avoid pytest state contamination
#### Pytest Test Isolation Issues (State Contamination)
1847
+
1848
+
**CRITICAL PROBLEM**: A persistent issue where tests pass individually but fail when run as part of the full test suite, affecting multiple plugins (energybalance, radiation, stomatalconductance).
1849
+
1850
+
**Symptoms**:
1851
+
- Tests pass when run with `pytest tests/test_yourplugin.py -v`
1852
+
- Same tests fail when run with `pytest` (full suite)
1853
+
- Import-related failures with class identity mismatches
1854
+
- Error messages like `AssertionError: False = issubclass(...)`
1855
+
1856
+
**Root Causes Identified**:
1857
+
1.**Global Plugin Registry State**: Plugin registry singleton persists contaminated state across test modules
1858
+
2.**Import Path Inconsistencies**: Different import paths for error classes cause class identity issues
1859
+
3.**Context Validation Issues**: `isinstance()` checks fail due to class identity problems during module reloading
1860
+
1861
+
**PERMANENT SOLUTION IMPLEMENTED** (v0.0.7+):
1862
+
1863
+
**1. Enhanced Test Fixture Architecture** (`conftest.py` - already fixed):
1864
+
```python
1865
+
@pytest.fixture(scope="module", autouse=True)
1866
+
defreset_plugin_state():
1867
+
"""Reset plugin registry state between test modules to prevent contamination."""
1868
+
# Reset at the start of each test module
1869
+
_reset_plugin_registry_if_available()
1870
+
yield
1871
+
# Reset at the end of each test module
1872
+
_reset_plugin_registry_if_available()
1873
+
1874
+
def_reset_plugin_registry_if_available():
1875
+
"""Reset plugin registry to prevent test contamination."""
1876
+
try:
1877
+
from pyhelios.plugins.registry import reset_plugin_registry
1878
+
reset_plugin_registry()
1879
+
exceptImportError:
1880
+
pass
1881
+
```
1882
+
1883
+
**2. Import Path Standardization** (REQUIRED for new plugins):
1884
+
```python
1885
+
# β CORRECT - Import from main pyhelios module
1886
+
from pyhelios import HeliosError, YourPluginError
1887
+
1888
+
# β WRONG - Direct import from exceptions module causes contamination
0 commit comments