()
| 654 | |
| 655 | |
| 656 | def test_patched_compile() -> None: |
| 657 | # ensure Source doesn't break |
| 658 | # when compile() modifies code dynamically |
| 659 | from builtins import compile |
| 660 | |
| 661 | def patched_compile1(_, *args, **kwargs): |
| 662 | return compile("", *args, **kwargs) |
| 663 | |
| 664 | with patch("builtins.compile", new=patched_compile1): |
| 665 | Source(patched_compile1).getstatement(1) |
| 666 | |
| 667 | # fmt: off |
| 668 | def patched_compile2(_, *args, **kwargs): |
| 669 | |
| 670 | # first line of this function (the one above this one) must be empty |
| 671 | # LINES must be equal or higher than number of lines of this function |
| 672 | LINES = 99 |
| 673 | return compile("\ndef a():\n" + "\n" * LINES + " pass", *args, **kwargs) |
| 674 | # fmt: on |
| 675 | |
| 676 | with patch("builtins.compile", new=patched_compile2): |
| 677 | Source(patched_compile2).getstatement(1) |
nothing calls this directly
no test coverage detected