| # Owner(s): ["oncall: package/deploy"] |
| from torch.utils._freeze import Freezer, PATH_MARKER |
| from torch.testing._internal.common_utils import run_tests, TestCase |
| class TestFreezer(TestCase): |
| """Tests the freeze.py script""" |
| def test_compile_string(self): |
| code_str = textwrap.dedent( |
| co = freezer.compile_string(code_str) |
| def verify_filename(co: types.CodeType): |
| if not isinstance(co, types.CodeType): |
| self.assertEqual(PATH_MARKER, co.co_filename) |
| for nested_co in co.co_consts: |
| verify_filename(nested_co) |
| # there is at least one nested code object besides the top level one |
| self.assertTrue(num_co >= 2) |
| if __name__ == "__main__": |