Skip to content

Conversation

@yingli-NREL
Copy link
Collaborator

@yingli-NREL yingli-NREL commented Jan 24, 2026

Original State:

  • Single file: tests/ecm_prep_test.py
  • Size: 129,354 lines
  • Framework: unittest
  • Structure: Monolithic, all 15 test classes in one file

Final State:

  • 15 separate test files, one per test class
  • Total size: 3,670 lines. Overall reduction: 97.2%. Uses pickle method for dramatic size reduction.
  • Framework: pytest
  • Structure: Modular, organized, maintainable

pytest advantages

  • More readable - Explicit fixture injection
  • Better isolation - Clear data dependencies
  • Easier debugging - Can inspect test_data fixture
  • More maintainable - Clearer structure
  • More flexible - Easy to add more fixtures

Major Directory Structure

tests/ecm_prep_test/
├── ...                     
├── archive/                               # Original 129K-line unittest file
│   └── ecm_prep_test_ORIGINAL.py      
│
├── data_generators/                       # Scripts to generate pickle files
│   ├── dump_merge_test_data.py           
│   ├── ...
│
├── test_data/                             # Pickle files with test data
│   ├── merge_measures_test_data.pkl      
│   ├── ...
│
└── Test files (pytest):  # 15 new test files
    ├── test_add_key_vals.py 
    ├── test_append_key_vals.py
    ├── test_check_markets.py
    ├── ...

Key Statistics:

Test Class Original Lines New Lines Change Method
YrMapTest 75 74 -1.3% Inline
AppendKeyValsTest 120 118 -1.7% Inline
CheckMarketsTest 80 112 +40.0% Inline
DivKeyValsTest 92 126 +37.0% Inline
DivKeyValsFloatTest 135 179 +32.6% Inline
AddKeyValsTest 125 190 +52.0% Inline
CreateKeyChainTest 211 226 +7.1% Inline
FillParametersTest 564 574 +1.8% Inline
CostConversionTest 573 591 +3.1% Inline
CleanUpTest 200 250 +25.0% Inline
MergeMeasuresTest 3,507 198 -94.4% Pickle
PartitionMicrosegmentTest 3,880 188 -95.2% Pickle
MarketUpdatesTest 19,401 478 -97.5% Pickle
TimeSensitiveValuationTest 44,697 94 -99.8% Pickle
UpdateMeasuresTest 55,694 272 -99.5% Pickle

@yingli-NREL yingli-NREL self-assigned this Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants