Created
December 8, 2011 13:36
-
-
Save jgosmann/1447004 to your computer and use it in GitHub Desktop.
Example of incompatibility between flexmock and numpy arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flexmock import * | |
import numpy as np | |
import unittest | |
class FlexmockNumpyTest(unittest.TestCase): | |
def testFlexmockNumpy(self): | |
someArray = np.array([[0, 1], [2, 3]]) | |
equalToSomeArray = someArray.copy() | |
mock = flexmock() | |
mock.should_receive("funcWithArrayArg").with_args(someArray) | |
mock.funcWithArrayArg(equalToSomeArray) | |
if __name__ == "__main__": | |
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
E. | |
====================================================================== | |
ERROR: testFlexmockNumpy (__main__.FlexmockNumpyTest) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "flexmock_numpy.py", line 13, in testFlexmockNumpy | |
mock.funcWithArrayArg(equalToSomeArray) | |
File "/Volumes/Home/blubb/bin/python/lib/python/flexmock.py", line 670, in mock_method | |
self, method, arguments) | |
File "/Volumes/Home/blubb/bin/python/lib/python/flexmock.py", line 104, in get_flexmock_expectation | |
if e.method == name and _match_args(args, e.args): | |
File "/Volumes/Home/blubb/bin/python/lib/python/flexmock.py", line 792, in _match_args | |
if (given_args == expected_args or expected_args is None): | |
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() | |
---------------------------------------------------------------------- | |
Ran 1 test in 0.046s | |
FAILED (errors=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment