potc.testing.trans

transobj_assert

potc.testing.trans.transobj_assert(obj: object, trans=None)[source]
Overview:

Assertion-based test for potc.translate.quick.transobj() function.

This function is managed by contextmanager, so you can use it with a with block.

Arguments:
Examples::
>>> with transobj_assert([1, -2, 3.2, '1234']) as obj, name:
...     assert obj == [1, -2, 3.2, '1234']
...     assert name == 'builtin_list'

Note

When this function is called, the translated object code will be dumped into a python file and then import from it, so please make sure the code you created can be supported by standard python grammar.

transvars_assert

potc.testing.trans.transvars_assert(vars_: Mapping[str, Any], trans=None, reformat=None, isort: bool = True)[source]
Overview:

Assertion-based test for potc.translate.quick.transvars() function.

This function is managed by contextmanager, so you can use it with a with block.

Arguments:
Examples::
>>> with transvars_assert({
...     'a': 233,
...     'b': [1, 2, 3, {'x': 1}],
... }) as (v, code):
...     assert v == {  # v is the mapping of the values
...         'a': 233,
...         'b': [1, 2, 3, {'x': 1}],
...     }
...     assert 'import' not in code  # code is the dumped source code

Note

When this function is called, the translated object code will be dumped into a python file and then import from it, so please make sure the code you created can be supported by standard python grammar.