@@ -770,7 +770,7 @@ def test_safe_cast_value_none_handling(self, model_with_datatypes) -> None:
770
770
771
771
GIVEN: A model with type casting capability
772
772
WHEN: Casting None values to different datatypes
773
- THEN: Should return appropriate default values (missing lines 134, 137-143)
773
+ THEN: Should return appropriate default values
774
774
"""
775
775
path = ("Battery" , "Specifications" , "Test" )
776
776
@@ -800,17 +800,17 @@ def test_safe_cast_value_none_handling_edge_cases(self, model_with_datatypes) ->
800
800
801
801
GIVEN: A model with type casting capability
802
802
WHEN: Casting None values to unusual datatypes
803
- THEN: Should handle gracefully (covers lines 141-143)
803
+ THEN: Should handle gracefully
804
804
"""
805
805
path = ("Battery" , "Specifications" , "Test" )
806
806
807
- # Test None to dict - covers line 141
807
+ # Test None to dict
808
808
result = model_with_datatypes ._safe_cast_value (None , dict , path )
809
809
assert result == {}
810
810
811
- # Test None with unknown datatype - covers line 143 (fallback case)
812
- class CustomType :
813
- pass
811
+ # Test None with unknown datatype
812
+ class CustomType : # pylint: disable=too-few-public-methods
813
+ """Dummy, just for testing."""
814
814
815
815
result = model_with_datatypes ._safe_cast_value (None , CustomType , path )
816
816
assert result == "" # Should return empty string for unknown types
@@ -821,16 +821,16 @@ def test_get_component_datatype_isinstance_comprehensive_coverage(self, model_wi
821
821
822
822
GIVEN: A model with component datatypes
823
823
WHEN: Accessing datatypes with various path scenarios
824
- THEN: Should execute isinstance check paths (covers lines 113-114)
824
+ THEN: Should execute isinstance check paths
825
825
"""
826
826
# Set up component datatypes with both type objects and non-type values
827
827
model_with_datatypes ._component_datatypes = {
828
828
"Battery" : {
829
829
"Specifications" : {
830
- "ValidType" : int , # This is a type - line 113
831
- "InvalidType" : "not_a_type" , # This is not a type - line 114
832
- "AnotherValidType" : str , # Another type - line 113
833
- "NonCallable" : 42 , # Not callable - line 114
830
+ "ValidType" : int , # This is a type
831
+ "InvalidType" : "not_a_type" , # This is not a type
832
+ "AnotherValidType" : str , # Another type
833
+ "NonCallable" : 42 , # Not callable
834
834
}
835
835
}
836
836
}
@@ -839,15 +839,15 @@ def test_get_component_datatype_isinstance_comprehensive_coverage(self, model_wi
839
839
datatype = model_with_datatypes ._get_component_datatype (("Battery" , "Specifications" , "ValidType" ))
840
840
assert datatype is int
841
841
842
- # Test another valid type (covers line 113 again)
842
+ # Test another valid type
843
843
datatype = model_with_datatypes ._get_component_datatype (("Battery" , "Specifications" , "AnotherValidType" ))
844
844
assert datatype is str
845
845
846
- # Test invalid type - string (covers line 114: else case)
846
+ # Test invalid type - string
847
847
datatype = model_with_datatypes ._get_component_datatype (("Battery" , "Specifications" , "InvalidType" ))
848
848
assert datatype is None
849
849
850
- # Test invalid type - number (covers line 114: else case)
850
+ # Test invalid type - number
851
851
datatype = model_with_datatypes ._get_component_datatype (("Battery" , "Specifications" , "NonCallable" ))
852
852
assert datatype is None
853
853
@@ -857,18 +857,18 @@ def test_safe_cast_value_list_dict_special_handling_direct(self, model_with_data
857
857
858
858
GIVEN: A model with type casting capability
859
859
WHEN: Attempting to cast to list or dict types
860
- THEN: Should execute special handling code and log error (covers lines 152-154)
860
+ THEN: Should execute special handling code and log error
861
861
"""
862
862
path = ("Battery" , "Specifications" , "TestField" )
863
863
864
- # Test list datatype - should hit line 152 check, log error, and fall back to _process_value
864
+ # Test list datatype - log error, and fall back to _process_value
865
865
result = model_with_datatypes ._safe_cast_value ("some_value" , list , path )
866
866
assert result == "some_value" # Falls back to _process_value which returns the original value
867
867
assert "Failed to cast value" in caplog .text
868
868
869
869
caplog .clear ()
870
870
871
- # Test dict datatype - should hit line 152 check, log error, and fall back to _process_value
871
+ # Test dict datatype - log error, and fall back to _process_value
872
872
result = model_with_datatypes ._safe_cast_value ("another_value" , dict , path )
873
873
assert result == "another_value" # Falls back to _process_value which returns the original value
874
874
assert "Failed to cast value" in caplog .text
@@ -879,20 +879,22 @@ def test_safe_cast_value_attribute_error_handling(self, model_with_datatypes, ca
879
879
880
880
GIVEN: A model with type casting capability
881
881
WHEN: A callable datatype raises AttributeError during instantiation
882
- THEN: Should catch AttributeError and fall back to _process_value (covers line 159)
882
+ THEN: Should catch AttributeError and fall back to _process_value
883
883
"""
884
884
path = ("Battery" , "Specifications" , "TestField" )
885
885
886
886
# Create a mock class that raises AttributeError when called
887
887
class AttributeErrorType (type ):
888
+ """Dummy, just for testing."""
889
+
888
890
def __call__ (cls , * args , ** kwargs ) -> None :
889
891
msg = "Mock AttributeError for testing"
890
892
raise AttributeError (msg )
891
893
892
- class MockDatatype (metaclass = AttributeErrorType ):
893
- pass
894
+ class MockDatatype (metaclass = AttributeErrorType ): # pylint: disable=too-few-public-methods
895
+ """Dummy, just for testing."""
894
896
895
- # This should trigger the AttributeError handling at line 159
897
+ # This should trigger the AttributeError handling
896
898
result = model_with_datatypes ._safe_cast_value ("test_value" , MockDatatype , path )
897
899
898
900
# Should log the error and fall back to _process_value
@@ -906,9 +908,9 @@ def test_deep_merge_dicts_recursive_comprehensive(self, model_with_datatypes) ->
906
908
907
909
GIVEN: A model instance with _deep_merge_dicts method
908
910
WHEN: Merging nested dictionaries with various structures
909
- THEN: Should handle all recursive paths (covers lines 259-260)
911
+ THEN: Should handle all recursive paths
910
912
"""
911
- # Test deep recursive merging (covers line 259: recursive call)
913
+ # Test deep recursive merging
912
914
default = {
913
915
"level1" : {
914
916
"level2" : {
@@ -936,7 +938,7 @@ def test_deep_merge_dicts_recursive_comprehensive(self, model_with_datatypes) ->
936
938
937
939
result = model_with_datatypes ._deep_merge_dicts (default , existing )
938
940
939
- # Verify deep recursive merging occurred (line 259)
941
+ # Verify deep recursive merging occurred
940
942
assert result ["level1" ]["level2" ]["level3" ]["default_value" ] == "from_default"
941
943
assert result ["level1" ]["level2" ]["level3" ]["existing_value" ] == "from_existing"
942
944
assert result ["level1" ]["level2" ]["level3" ]["shared_key" ] == "existing_shared"
@@ -947,7 +949,7 @@ def test_deep_merge_dicts_recursive_comprehensive(self, model_with_datatypes) ->
947
949
assert result ["top_level_default" ] == "default"
948
950
assert result ["top_level_existing" ] == "existing"
949
951
950
- # Test case where existing value is not a dict (covers line 260: else case)
952
+ # Test case where existing value is not a dict
951
953
default_with_dict = {"mixed_key" : {"nested" : "should_not_appear" }}
952
954
953
955
existing_with_string = {
@@ -956,7 +958,7 @@ def test_deep_merge_dicts_recursive_comprehensive(self, model_with_datatypes) ->
956
958
957
959
result = model_with_datatypes ._deep_merge_dicts (default_with_dict , existing_with_string )
958
960
959
- # existing value should be preserved (line 260: result[key] = existing[key])
961
+ # existing value should be preserved
960
962
assert result ["mixed_key" ] == "string_value"
961
963
assert not isinstance (result ["mixed_key" ], dict )
962
964
@@ -966,14 +968,14 @@ def test_process_value_none_and_version_handling(self, model_with_datatypes) ->
966
968
967
969
GIVEN: A model instance
968
970
WHEN: Processing None values and Version fields
969
- THEN: Should handle appropriately (covers line 173)
971
+ THEN: Should handle appropriately
970
972
"""
971
- # Test None value handling (covers line 173: if value is None)
973
+ # Test None value handling
972
974
path = ("Battery" , "Specifications" , "TestField" )
973
975
result = model_with_datatypes ._process_value (path , None )
974
976
assert result == ""
975
977
976
- # Test Version field special handling (covers version check)
978
+ # Test Version field special handling
977
979
version_path = ("Battery" , "Product" , "Version" )
978
980
result = model_with_datatypes ._process_value (version_path , "1.2.3-beta" )
979
981
assert result == "1.2.3-beta"
0 commit comments