<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>atsuoishimoto</author_name>
  <author_url>https://blog.hatena.ne.jp/atsuoishimoto/</author_url>
  <blog_title>atsuoishimoto's diary</blog_title>
  <blog_url>https://atsuoishimoto.hatenablog.com/</blog_url>
  <categories>
  </categories>
  <description>unittest.mock モジュールを正しく使って関数を置き換えるというのは以外と難しいもので、Pythonの名前空間について、しっかり把握できてないとうまくいかないことがある。 単純なケースでは、テスト対象のコードが参照している名前で置き換えてやればいい。 例えば import spam def ham(): spam.egg() というモジュール M の ham() をテストするために spam.egg を置き換えるなら def test(): import M with patch(&quot;spam.egg&quot;): M.ham() となる。また、 from spam import egg de…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fatsuoishimoto.hatenablog.com%2Fentry%2F2013%2F07%2F27%2F000000&quot; title=&quot;めんどくさいmock.patch() - atsuoishimoto&amp;#39;s diary&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2013-07-27 00:00:00</published>
  <title>めんどくさいmock.patch()</title>
  <type>rich</type>
  <url>https://atsuoishimoto.hatenablog.com/entry/2013/07/27/000000</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
