unittest.mock ã¢ã¸ã¥ã¼ã«ãæ£ãã使ã£ã¦é¢æ°ãç½®ãæããã¨ããã®ã¯ä»¥å¤ã¨é£ãããã®ã§ãPythonã®åå空éã«ã¤ãã¦ããã£ããææ¡ã§ãã¦ãªãã¨ãã¾ããããªããã¨ãããã åç´ãªã±ã¼ã¹ã§ã¯ããã¹ã対象ã®ã³ã¼ããåç §ãã¦ããååã§ç½®ãæãã¦ããã°ããã ä¾ãã° import spam def ham(): spam.egg() ã¨ããã¢ã¸ã¥ã¼ã« M ã® ham() ããã¹ãããããã« spam.egg ãç½®ãæãããªã def test(): import M with patch("spam.egg"): M.ham() ã¨ãªããã¾ãã from spam import egg def ham(): egg() ã®ããã« egg ãåç §ãã¦ããå ´åãham() ã®å é¨ã§ã® egg 㯠M.egg ã¸ã®åç §ãªã®ã§ def test(): import M with patch("M
{{#tags}}- {{label}}
{{/tags}}