title: Mocking with Flexmock datetime.datetime.now
body: <p>I am trying to use different tools for mocking and find out the best one. I really like flexmock for its simplicity but I cant figure out how to mock behaving of datetime.datetime.now().</p>
  
  <p>How to mock following behaviour in flexmock?</p>
  
  <pre><code>&gt;&gt;&gt; from datetime import datetime
  &gt;&gt;&gt; mocker = Mocker()
  &gt;&gt;&gt; fake_datetime=mocker.replace(datetime)
  &gt;&gt;&gt; fake_datetime.now()
  &lt;mocker.Mock object at 0x027F1990&gt;
  &gt;&gt;&gt; mocker.result(datetime(year=2012, month=12, day=12))
  &gt;&gt;&gt; mocker.replay()
  &gt;&gt;&gt; datetime.now()
  datetime.datetime(2012, 12, 12, 0, 0)
  </code></pre>
  
  <p>When I try same in flexmock :</p>
  
  <pre><code>&gt;&gt;&gt; from datetime import datetime  
  &gt;&gt;&gt; fake_datetime = flexmock(datetime)
  Traceback (most recent call last):
    File "C:\virtualenvs\webui\lib\site-packages\flexmock.py", line 1194, in flexmock
      return _create_partial_mock(spec, **kwargs)
    File "C:\virtualenvs\webui\lib\site-packages\flexmock.py", line 1013, in 
  _create_partial_mock
  if (_attach_flexmock_methods(mock, Mock, obj_or_class) and
    File "C:\virtualenvs\webui\lib\site-packages\flexmock.py", line 1030, in
  _attach_flexmock_methods
  'Python does not allow you to mock builtin objects or modules. '
      'Python does not allow you to mock builtin objects or modules. '
  MockBuiltinError: Python does not allow you to mock builtin objects or modules.
  Consider wrapping it in a class you can mock instead
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&gt;&gt;&gt;flexmock(datetime).should_receive('datetime.now').and_return(datetime.datetime(2012,12,10))
  &gt;&gt;&gt; datetime.datetime.now()
  Traceback (most recent call last):
    File "&lt;console&gt;", line 1, in &lt;module&gt;
  AttributeError: 'function' object has no attribute 'now'
  </code></pre>