Skip to content

Commit 01c055a

Browse files
committed
fix: ensure size_of is exported from algopy module
1 parent 98e6816 commit 01c055a

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/algopy/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from _algopy_testing.primitives import Array, BigUInt, Bytes, ImmutableArray, String, UInt64
1818
from _algopy_testing.protocols import BytesBacked
1919
from _algopy_testing.state import Box, BoxMap, BoxRef, GlobalState, LocalState
20-
from _algopy_testing.utilities import OpUpFeeSource, ensure_budget, log
20+
from _algopy_testing.utilities import OpUpFeeSource, ensure_budget, log, size_of
2121

2222
from . import arc4, gtxn, itxn, op
2323

@@ -59,6 +59,7 @@
5959
"logicsig",
6060
"op",
6161
"subroutine",
62+
"size_of",
6263
"uenumerate",
6364
"urange",
6465
]

tests/utilities/test_size_of.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import re
21
import typing
32

43
import pytest
5-
from _algopy_testing.utilities.size_of import size_of
6-
from algopy import Account, Application, Asset, Bytes, String, UInt64, arc4
4+
from algopy import Account, Application, Asset, Bytes, String, UInt64, arc4, size_of
75

86

97
class Swapped(arc4.Struct):
@@ -52,14 +50,16 @@ def test_size_of() -> None:
5250
assert size_of(arc4.StaticArray(arc4.Byte(), arc4.Byte())) == 2
5351
assert size_of(Swapped) == 52
5452

55-
with pytest.raises(ValueError, match=re.compile("is dynamically sized")):
56-
size_of(arc4.StaticArray[arc4.DynamicBytes, typing.Literal[7]])
5753

58-
with pytest.raises(ValueError, match=re.compile("is dynamically sized")):
59-
size_of(tuple[arc4.DynamicBytes, Bytes])
60-
61-
with pytest.raises(ValueError, match=re.compile("is dynamically sized")):
62-
size_of(arc4.Tuple[arc4.UInt64, arc4.String])
63-
64-
with pytest.raises(ValueError, match=re.compile("is dynamically sized")):
65-
size_of(MyDynamicSizedTuple)
54+
@pytest.mark.parametrize(
55+
"typ",
56+
[
57+
arc4.StaticArray[arc4.DynamicBytes, typing.Literal[7]],
58+
tuple[arc4.DynamicBytes, Bytes],
59+
arc4.Tuple[arc4.UInt64, arc4.String],
60+
MyDynamicSizedTuple,
61+
],
62+
)
63+
def test_size_of_dynamic(typ: type) -> None:
64+
with pytest.raises(ValueError, match="is dynamically sized"):
65+
size_of(typ)

0 commit comments

Comments
 (0)