[Python-Dev] [Python-checkins] cpython (merge 3.2 -> default): MERGE: Better test for Issue #15402: Add a __sizeof__ method to struct.Struct

Jesus Cea jcea at jcea.es
Mon Jul 23 18:38:30 CEST 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 23/07/12 18:27, Meador Inge wrote:
> Doc/ACKS.txt is *only* for acknowledging documentation
> contributions. Serhiy is already in Misc/ACKS.  No need to add him
> to Doc/ACKS.txt.

Oh, I missed that. Thanks for the head up.

> As for the tests, I intentionally kept them the way that Serhiy
> contributed them -- using >= instead of >.  I kept them this way
> because we also discussed in issue14596 the prospect of optimizing
> the way repeat counts are handled.  These tests would start failing
> if (when) that optimization happens.

The problem is that if we do ">=", then an unpatched python
interpreter could pass the test too. So we are not actually testing
the feature.

If the repeat counters are going to be optimized, the obvious step
would be to upgrade the test to do something like "BHHIL" instead of
"123B". I would wait until this feature is implemented to update the test.

What do you think?.

> 
> So, neither of these changes are really necessary.  Although, it
> wouldn't hurt to have *additional* tests using the > relation.
> 
>> 
>> diff --git a/Doc/ACKS.txt b/Doc/ACKS.txt --- a/Doc/ACKS.txt +++
>> b/Doc/ACKS.txt @@ -205,6 +205,7 @@ * Anthony Starks * Greg Stein 
>> * Peter Stoehr +   * Serhiy Storchaka * Mark Summerfield * Reuben
>> Sumner * Kalle Svensson diff --git a/Lib/test/test_struct.py
>> b/Lib/test/test_struct.py --- a/Lib/test/test_struct.py +++
>> b/Lib/test/test_struct.py @@ -575,12 +575,12 @@ def
>> test_sizeof(self): 
>> self.assertGreater(sys.getsizeof(struct.Struct('BHILfdspP')), 
>> sys.getsizeof(struct.Struct('B'))) -
>> self.assertGreaterEqual(sys.getsizeof(struct.Struct('123B')), +
>> self.assertGreater(sys.getsizeof(struct.Struct('123B')), 
>> sys.getsizeof(struct.Struct('B'))) -
>> self.assertGreaterEqual(sys.getsizeof(struct.Struct('B' * 123)), 
>> +        self.assertGreater(sys.getsizeof(struct.Struct('B' *
>> 1234)), sys.getsizeof(struct.Struct('123B'))) -
>> self.assertGreaterEqual(sys.getsizeof(struct.Struct('123xB')), -
>> sys.getsizeof(struct.Struct('B'))) +
>> self.assertGreater(sys.getsizeof(struct.Struct('1234B')), +
>> sys.getsizeof(struct.Struct('123B')))
>> 
>> def test_main(): run_unittest(StructTest)
>> 
>> -- Repository URL: http://hg.python.org/cpython
>> 
>> _______________________________________________ Python-checkins
>> mailing list Python-checkins at python.org 
>> http://mail.python.org/mailman/listinfo/python-checkins
>> 
> 
> 
> 

- -- 
Jesus Cea Avion                         _/_/      _/_/_/        _/_/_/
jcea at jcea.es - http://www.jcea.es/     _/_/    _/_/  _/_/    _/_/  _/_/
jabber / xmpp:jcea at jabber.org         _/_/    _/_/          _/_/_/_/_/
.                              _/_/  _/_/    _/_/          _/_/  _/_/
"Things are not so easy"      _/_/  _/_/    _/_/  _/_/    _/_/  _/_/
"My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQCVAwUBUA1+Bplgi5GaxT1NAQJtSAQAkv5DyoQ1N1YdOH2QLHnFbOsvp/1aG0Vy
hHMlD6cu/L7Ub+gyWWo65v9Dp4sLahV+CYem1wL4Fzd2QyBNQdg+BNou9eqoDzGF
IJbY2HALwOwz1vgeBiamFOSvpyWya/hzXR9I7rkBqXdR9c2Njdl/ioZQNKETO05k
TRfd/BQas4k=
=TKFO
-----END PGP SIGNATURE-----


More information about the Python-Dev mailing list