alfredodeza / helga-karma

You're doing good work!
MIT License
3 stars 4 forks source link

test failure: AttributeError: assertCalledWith #16

Open ktdreyer opened 9 years ago

ktdreyer commented 9 years ago

I'm using Fedora 22, Python 2.7.10 , pytest-2.7.2, mock-1.3.0, and I'm getting a couple failures about "assertCalledWith":

======================================================================
ERROR: test_unalias (tests.test_plugin.TestKarmaPlugin)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/kdreyer/dev/helga-karma/tests/test_plugin.py", line 160, in test_unalias
    user2.remove_alias.assertCalledWith(user1)
  File "/home/kdreyer/dev/helga-karma/venv/lib/python2.7/site-packages/mock/mock.py", line 721, in __getattr__
    raise AttributeError(name)
AttributeError: assertCalledWith

Switching assertCalledWith to assert_called_with eliminates the errors, but then two tests fail:

======================================================================
FAIL: test_give (tests.test_plugin.TestKarmaPlugin)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/kdreyer/dev/helga-karma/tests/test_plugin.py", line 34, in test_give
    from_user.give_karma_to.assert_called_with(to_user)
  File "/home/kdreyer/dev/helga-karma/venv/lib/python2.7/site-packages/mock/mock.py", line 925, in assert_called_with
    raise AssertionError('Expected call: %s\nNot called' % (expected,))
AssertionError: Expected call: give_karma_to(<Mock id='140330327229776'>)
Not called

======================================================================
FAIL: test_unalias (tests.test_plugin.TestKarmaPlugin)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/kdreyer/dev/helga-karma/tests/test_plugin.py", line 160, in test_unalias
    user2.remove_alias.assert_called_with(user1)
  File "/home/kdreyer/dev/helga-karma/venv/lib/python2.7/site-packages/mock/mock.py", line 925, in assert_called_with
    raise AssertionError('Expected call: %s\nNot called' % (expected,))
AssertionError: Expected call: remove_alias(<Mock id='140330326771728'>)
Not called

----------------------------------------------------------------------
Ran 42 tests in 0.073s

FAILED (failures=2)
ktdreyer commented 8 years ago

This is now fixed in my testing.

============================= test session starts ==============================
platform linux2 -- Python 2.7.10 -- py-1.4.30 -- pytest-2.7.2
rootdir: /home/kdreyer/dev/helga-karma, inifile: 
collected 83 items 

tests/test_data.py ...............
tests/test_integration.py .............
tests/test_plugin.py .......................................................

========================== 83 passed in 0.28 seconds ===========================