[issue26752] Mock(2.0.0).assert_has_calls() raise AssertionError in two same calls
John W. added the comment: This also seems to apply to unittest.mock in Python3.4. I described my similar issue on SO: http://stackoverflow.com/questions/42212433/what-is-wrong-with-this-simple-py-test-use-case It seems like it may be the same issue described here. For reference, this is my repro case: from unittest.mock import patch, call class Foo: def __init__(self): pass def my_method(self, value): pass def test_foo(): with patch('test.Foo', autospec=True) as MockFoo: m = MockFoo() m.my_method(123) MockFoo.assert_has_calls([call(), call().my_method(123)]) It fails with: ... E AssertionError: Calls not found. E Expected: [call(), call().my_method(123)] E Actual: [call(), call().my_method(123)] Which seems nonsensical to me. Removing the `value` parameter and the `123` arguments in the test makes it pass(!) -- nosy: +jwdevel versions: +Python 3.4 ___ Python tracker <http://bugs.python.org/issue26752> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26752] Mock(2.0.0).assert_has_calls() raise AssertionError in two same calls
John W. added the comment: This got a little discussion over at http://lists.idyll.org/pipermail/testing-in-python/2017-February/007012.html The current evidence seem to indicate this is indeed a bug in the implementation of assert_has_calls. -- ___ Python tracker <http://bugs.python.org/issue26752> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19875] test_getsockaddrarg occasional failure
John W. O'Brien added the comment: For reference: CPython code comments showing that this may be an anticipated problem: http://hg.python.org/cpython/file/0830670a9d9d/Lib/test/support/__init__.py#l562 An example of another project that seems to have tackled this problem in the way neologix suggests: http://openvswitch.org/pipermail/dev/2013-April/026430.html I am inclined to frame this issue as a choice between LBYL (try to predict, subject to the race, whether a port will be available) and EAFP (blindly try a few random high ports before inferring failure). -- nosy: +neirbowj ___ Python tracker <http://bugs.python.org/issue19875> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8735] optparse: parse_args(values=...) does not set up default values
New submission from John W. Shipman : optparse's .parse_args() method has a 'values=...' keyword argument that is documented as: 'object to store option arguments in (default: a new instance of optparse.Values)' There is no description of what types this argument may have. I was writing a class to digest the command line, and my bright idea was to request that .parse_args deposit the attribute values right into 'self' in the class constructor. This works only for arguments that were actually specified; it stores no attribute value at all for missing options that have associated default options. Below is a small script that demonstrates this behavior. It accepts one '-t' option, with default value 'DEFAULT'. Here is the output when the option is specified, and when it is not: $ bad -t foo foo $ bad Traceback (most recent call last): File "bad", line 23, in main() File "bad", line 13, in main print args.test AttributeError: Args instance has no attribute 'test' Here is the test script: #!/usr/bin/env python # # bad: Demonstrate defect in optparse. # I want optparse to honor the .parse_args(values=...) # argument to store the attributes directly in self in the # constructor. It works only for options actually specified; # default values are not copied into self. # import sys, optparse def main(): args = Args() print args.test class Args: def __init__(self): parser = optparse.OptionParser() parser.add_option ( "-t", "--test", dest="test", type="string", default="DEFAULT" ) discard, positionals = parser.parse_args(values=self) if __name__ == "__main__": main() -- -- components: Library (Lib) messages: 105875 nosy: j...@nmt.edu priority: normal severity: normal status: open title: optparse: parse_args(values=...) does not set up default values type: behavior versions: Python 2.6 ___ Python tracker <http://bugs.python.org/issue8735> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com