Just tried it out and it seems to work for me. Maybe copying and pasting the path name is causing you problems?
This is what i did.
# Select two material assets in the content browser based on a bad to good order
mats = unreal.GlobalEditorUtilityBase.get_default_object().get_selected_assets()
replace_material(mats[0].get_path_name(), mats[1].get_path_name())