|
18 | 18 | from _algopy_testing.models.account import AccountFields |
19 | 19 | from _algopy_testing.models.application import ApplicationContextData, ApplicationFields |
20 | 20 | from _algopy_testing.models.asset import AssetFields |
21 | | -from _algopy_testing.utils import generate_random_int, get_type_generic_from_int_literal |
| 21 | +from _algopy_testing.utils import generate_random_int |
22 | 22 |
|
23 | 23 | if typing.TYPE_CHECKING: |
24 | 24 | import algopy |
@@ -200,15 +200,18 @@ def bytes(self, length: int | None = None) -> algopy.Bytes: |
200 | 200 | length = length or MAX_BYTES_SIZE |
201 | 201 | return _algopy_testing.Bytes(secrets.token_bytes(length)) |
202 | 202 |
|
203 | | - def fixed_bytes(self, length: _TBytesLength) -> algopy.FixedBytes[_TBytesLength]: |
| 203 | + def fixed_bytes( |
| 204 | + self, fixed_bytes_type: type[algopy.FixedBytes[_TBytesLength]] |
| 205 | + ) -> algopy.FixedBytes[_TBytesLength]: |
204 | 206 | """Generate a random fixed byte sequence of a specified length. |
205 | 207 |
|
206 | | - :param length: Length of the fixed byte sequence. |
| 208 | + :param fixed_bytes_type: The FixedBytes type with length parameter (e.g., |
| 209 | + FixedBytes[typing.Literal[10]]). |
207 | 210 | :returns: The randomly generated fixed byte sequence. |
208 | 211 | """ |
209 | | - |
210 | | - length_t = get_type_generic_from_int_literal(length) |
211 | | - return _algopy_testing.FixedBytes[length_t](secrets.token_bytes(length)) # type: ignore[valid-type] |
| 212 | + # Extract the length from the type parameter |
| 213 | + length = fixed_bytes_type._length |
| 214 | + return fixed_bytes_type(secrets.token_bytes(length)) |
212 | 215 |
|
213 | 216 |
|
214 | 217 | def _get_app_id(app: algopy.Application | algopy.UInt64 | int) -> int: |
|
0 commit comments