@@ -670,7 +670,7 @@ def test_finalize_frame_series_name():
670670 assert result .name is None
671671
672672# ----------------------------------------------------------------------------
673- # Merge tests
673+ # Tests for merge
674674
675675@pytest .mark .parametrize (["allow_duplication_on_left" , "allow_duplication_on_right" ],
676676[
@@ -689,14 +689,29 @@ def test_merge_sets_duplication_allowance_flag(allow_duplication_on_left, allow_
689689 Otherwise, the result should have its flag set to True.
690690 """
691691 # Arrange
692+ left = pd .DataFrame ({"test" : [1 ]}).set_flags (allows_duplicate_labels = allow_duplication_on_left )
693+ right = pd .DataFrame ({"test" : [1 ]}).set_flags (allows_duplicate_labels = allow_duplication_on_right )
694+
695+ # Act
696+ result = left .merge (right , how = "inner" , on = "test" )
697+
698+ # Assert
699+ expected_duplication_allowance = allow_duplication_on_left and allow_duplication_on_right
700+ assert result .flags .allows_duplicate_labels == expected_duplication_allowance
701+
702+ def test_merge_collects_metadata_from_both_inputs ():
703+ """
704+ Check that pandas.merge sets the metadata of its result by merging the metadata from both
705+ of its inputs.
706+ """
707+ # Arrange
692708 left = pd .DataFrame ({"test" : [1 ]})
693- left .set_flags ( allows_duplicate_labels = allow_duplication_on_left )
709+ left .attrs = { "a" : 2 }
694710 right = pd .DataFrame ({"test" : [1 ]})
695- right .set_flags ( allows_duplicate_labels = allow_duplication_on_right )
711+ right .attrs = { "b" : 3 }
696712
697713 # Act
698714 result = left .merge (right , how = "inner" , on = "test" )
699715
700716 # Assert
701- expected_duplication_allowance = allow_duplication_on_left and allow_duplication_on_right
702- assert result .flags .allows_duplicate_labels == expected_duplication_allowance
717+ assert result .attrs == {"a" : 2 , "b" : 3 }
0 commit comments