11"""Unit tests for extraction utilities."""
22
33from vivarium_profiling .tools .extraction import (
4- CallPattern ,
54 ExtractionConfig ,
5+ FunctionCallConfiguration ,
66 bottleneck_config ,
77 extract_runtime ,
88 parse_function_metrics ,
99 phase_config ,
1010)
1111
1212
13- class TestCallPattern :
14- """Tests for CallPattern dataclass."""
13+ class TestFunctionCallConfiguration :
14+ """Tests for FunctionCallConfiguration dataclass."""
1515
16- def test_call_pattern_defaults (self ):
17- """Test CallPattern with default extraction flags."""
18- pattern = CallPattern (name = "test_func" , filename = "test.py" , function_name = "test_func" )
16+ def test_function_call_configuration_defaults (self ):
17+ """Test FunctionCallConfiguration with default extraction flags."""
18+ pattern = FunctionCallConfiguration (
19+ name = "test_func" , filename = "test.py" , function_name = "test_func"
20+ )
1921
2022 assert pattern .name == "test_func"
2123 assert pattern .filename == "test.py"
@@ -29,9 +31,9 @@ def test_call_pattern_defaults(self):
2931 assert pattern .ncalls_col == "test_func_ncalls"
3032 assert pattern .columns == ["test_func_cumtime" ]
3133
32- def test_call_pattern_all_extracts (self ):
33- """Test CallPattern with all extraction flags enabled."""
34- pattern = CallPattern (
34+ def test_function_call_configuration_all_extracts (self ):
35+ """Test FunctionCallConfiguration with all extraction flags enabled."""
36+ pattern = FunctionCallConfiguration (
3537 name = "bottleneck" ,
3638 filename = "test.py" ,
3739 function_name = "bottleneck" ,
@@ -47,9 +49,9 @@ def test_call_pattern_all_extracts(self):
4749 "bottleneck_ncalls" ,
4850 ]
4951
50- def test_call_pattern_custom_templates (self ):
51- """Test CallPattern with custom column templates."""
52- pattern = CallPattern (
52+ def test_function_call_configuration_custom_templates (self ):
53+ """Test FunctionCallConfiguration with custom column templates."""
54+ pattern = FunctionCallConfiguration (
5355 name = "phase" ,
5456 filename = "engine.py" ,
5557 function_name = "phase" ,
@@ -76,7 +78,7 @@ def test_extraction_config_defaults(self):
7678 def test_extraction_config_custom_patterns (self ):
7779 """Test ExtractionConfig with custom patterns."""
7880 patterns = [
79- CallPattern ("func1" , "test.py" , "func1" ),
81+ FunctionCallConfiguration ("func1" , "test.py" , "func1" ),
8082 bottleneck_config ("func2" , "test.py" , "func2" ),
8183 ]
8284 config = ExtractionConfig (patterns = patterns )
@@ -87,16 +89,18 @@ def test_extraction_config_custom_patterns(self):
8789 def test_metric_columns (self ):
8890 """Test metric_columns property."""
8991 patterns = [
90- CallPattern ("a" , "test.py" , "a" , extract_cumtime = True , extract_percall = True ),
91- CallPattern ("b" , "test.py" , "b" , extract_cumtime = True ),
92+ FunctionCallConfiguration (
93+ "a" , "test.py" , "a" , extract_cumtime = True , extract_percall = True
94+ ),
95+ FunctionCallConfiguration ("b" , "test.py" , "b" , extract_cumtime = True ),
9296 ]
9397 config = ExtractionConfig (patterns = patterns )
9498
9599 assert config .metric_columns == ["a_cumtime" , "a_percall" , "b_cumtime" ]
96100
97101 def test_results_columns (self ):
98102 """Test results_columns includes base columns."""
99- patterns = [CallPattern ("test" , "test.py" , "test" )]
103+ patterns = [FunctionCallConfiguration ("test" , "test.py" , "test" )]
100104 config = ExtractionConfig (patterns = patterns )
101105
102106 cols = config .results_columns
@@ -181,7 +185,7 @@ def test_extract_metrics_default_patterns(self, sample_stats_file):
181185 def test_extract_metrics_custom_patterns (self , sample_stats_file ):
182186 """Test extracting metrics with custom patterns."""
183187 patterns = [
184- CallPattern (
188+ FunctionCallConfiguration (
185189 "custom_func" ,
186190 "some/custom/module.py" ,
187191 "custom_function" ,
@@ -202,7 +206,7 @@ def test_extract_metrics_custom_patterns(self, sample_stats_file):
202206
203207 def test_extract_metrics_missing_patterns (self , sample_stats_file ):
204208 """Test extracting metrics when patterns don't match."""
205- patterns = [CallPattern ("missing" , "nonexistent.py" , "missing" )]
209+ patterns = [FunctionCallConfiguration ("missing" , "nonexistent.py" , "missing" )]
206210 config = ExtractionConfig (patterns = patterns )
207211 metrics = config .extract_metrics (sample_stats_file )
208212
0 commit comments