Skip to content

Commit

Permalink
test_Path.py: Fix path ordering when both sources are same size
Browse files Browse the repository at this point in the history
The paths are sorted in an unexpected way. Test both cases (though
only one case happens per Python version), and document what is
going on behind the test case.

In Python 3.11 both the object and the list have the same size. The
object grew by 8 bytes compared to Python 3.10.

For #41
  • Loading branch information
zhuyifei1999 committed May 13, 2023
1 parent b1af54e commit 609e62c
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion guppy/heapy/test/test_Path.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,11 @@ def str_address(x): return '<address>'
b = list(it)
self.aseq(str(a), str(b))

self.aseq(o.getvalue(), """\
# The sort order is based on the source set's byid partition (see
# Path.PathsIter.reset), which sorts based on the size, then render
# (see Part.IdentityPartition.__init__)
if sys.getsizeof(y) > sys.getsizeof(ob):
self.aseq(o.getvalue(), """\
0: hpy().Root.i0_sysdict
0: Src.i0_modules['sys'].__dict__
0: hpy().Root.i0_sysdict
Expand All @@ -781,6 +785,23 @@ def str_address(x): return '<address>'
0: <1 list: <address>*1>[0]
1: <1 __main__.O: <address>>.x
""".replace('__main__', self.__module__))
else:
self.aseq(o.getvalue(), """\
0: hpy().Root.i0_sysdict
0: Src.i0_modules['sys'].__dict__
0: hpy().Root.i0_sysdict
0: hpy().Root.i0_sysdict
0: Src[0][0][0]
0: Src[0][0][0]
0: Src[0]
0: Src.x
0: <1 list: <address>*1>[0]
0: <1 list: <address>*1>[0]
0: <1 __main__.O: <address>>.x
1: <1 list: <address>*1>[0]
0: <1 __main__.O: <address>>.x
1: <1 list: <address>*1>[0]
""".replace('__main__', self.__module__))

def test_2(self):
# To assist interactivity,
Expand Down

0 comments on commit 609e62c

Please sign in to comment.