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

Meador Inge meadori at gmail.com
Mon Jul 23 18:27:44 CEST 2012


On Mon, Jul 23, 2012 at 11:17 AM, jesus.cea <python-checkins at python.org> wrote:

> http://hg.python.org/cpython/rev/b9a3ed1b14b9
> changeset:   78260:b9a3ed1b14b9
> parent:      78257:03063e718f5f
> parent:      78259:1911e192af0d
> user:        Jesus Cea <jcea at jcea.es>
> date:        Mon Jul 23 18:16:18 2012 +0200
> summary:
>   MERGE: Better test for Issue #15402: Add a __sizeof__ method to struct.Struct
>
> files:
>   Doc/ACKS.txt            |  1 +
>   Lib/test/test_struct.py |  8 ++++----
>   2 files changed, 5 insertions(+), 4 deletions(-)

Jesús,

Doc/ACKS.txt is *only* for acknowledging documentation contributions.
Serhiy is already in Misc/ACKS.  No need to add him to Doc/ACKS.txt.

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.

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
>



-- 
# Meador


More information about the Python-Dev mailing list