livery.extensions.pytest._runner¶
livery.extensions.pytest._runner ¶
Per-item pytest process runner with read-set recording (Phase C2).
Runs each test file in its own pytest process, starting files with no
recorded duration first and then the longest files first so the tail
stays short. Each process runs under the .pth observer hook
(livery.extensions.pytest._observer), and collected items write their
verdicts and recorded read-sets to the workshop's proved record. An item
that collects no tests (pytest exit code 5) writes no row and is not a
failure.
Classes:
| Name | Description |
|---|---|
ItemOutcome |
Result of executing one test item in its own pytest process. |
Functions:
| Name | Description |
|---|---|
order_items |
Order items for scheduling: unmeasured first, then longest first. |
runner_config_reads |
Runner configuration files that govern item: existing hashes and absent paths. |
declared_test_reads |
Expand a package's |
run_items |
Run every test file in items in its own observed pytest process. |
item_runner |
Answer |
ci_item_runner |
Answer |
Attributes:
| Name | Type | Description |
|---|---|---|
EXIT_NO_TESTS |
|
|
CHANGED_ITEM_REPEATS |
|
|
PROFILE_DIR_VARIABLE |
|
|
RUNNER_CONFIG_FILES |
tuple[str, ...]
|
|
RUNNER_CONFIG_FILES
module-attribute
¶
ItemOutcome
dataclass
¶
ItemOutcome(item: str, code: int, collected: bool, verdict: str, stdout: str, stderr: str, read_set: ItemReadSet | None, duration: float, repeats: int = 1, repeat_verdicts: tuple[str, ...] = (), escaped: bool = False, escape_changed: tuple[str, ...] = ())
Result of executing one test item in its own pytest process.
Attributes:
| Name | Type | Description |
|---|---|---|
item |
str
|
Repository-relative POSIX path of the test file. |
code |
int
|
Raw pytest exit code. |
collected |
bool
|
|
verdict |
str
|
|
stdout |
str
|
Captured standard output. |
stderr |
str
|
Captured standard error. |
read_set |
ItemReadSet | None
|
Recorded |
duration |
float
|
Wall-clock duration in seconds for this item's process. |
repeats |
int
|
How many repeat processes ran for this item. |
repeat_verdicts |
tuple[str, ...]
|
Verdict of each repeat process in execution order. |
escaped |
bool
|
|
escape_changed |
tuple[str, ...]
|
Files changed since the proving row when |
order_items ¶
Order items for scheduling: unmeasured first, then longest first.
A test file with no entry in durations starts before every measured file (sorted alphabetically among unmeasured files). Measured files follow in descending duration order, tie-broken alphabetically.
Source code in packages/extensions/pytest/src/livery/extensions/pytest/_runner.py
runner_config_reads ¶
runner_config_reads(root: Path, item: str, *, package: Package | None = None) -> tuple[dict[str, str], tuple[str, ...]]
Runner configuration files that govern item: existing hashes and absent paths.
Includes root pytest.toml and .coveragerc, every ancestor
conftest.py from item's directory up to root, and the owning
package's workshop.toml and pyproject.toml. Missing paths land
in absent so creating one invalidates the item.
Source code in packages/extensions/pytest/src/livery/extensions/pytest/_runner.py
declared_test_reads ¶
declared_test_reads(root: Path, package_path: str, patterns: Sequence[str]) -> tuple[dict[str, str], tuple[str, ...], dict[str, str]]
Expand a package's [tests] reads patterns into files, absent, and dirs.
Source code in packages/extensions/pytest/src/livery/extensions/pytest/_runner.py
run_items ¶
run_items(root: Path, items: Sequence[str], *, pytest_args: Sequence[str] = (), env: Mapping[str, str] | None = None, durations: Mapping[str, float] | None = None, max_workers: int | None = None, record: bool = False, shadow: bool = False, select: bool = False, audit: bool = False, local: bool = False, sums_file: Path | None = None, step: str = 'test.pytest', store: StateStore | None = None, python_exe: str = '', on_start: Callable[[str], None] | None = None, repeat_items: frozenset[str] = frozenset(), repeat_count: int = CHANGED_ITEM_REPEATS) -> tuple[ItemOutcome, ...]
Run every test file in items in its own observed pytest process.
Starts unmeasured files first, then longest files first. Items in
repeat_items run repeat_count times concurrently with distinct
PYTHONHASHSEED values so flaky tests are caught immediately.
When select is true (and audit is false), packages with
[tests] selection = "on" skip proved items unless an active escape
put the package back to whole runs. When audit is true (scheduled
runs), every item executes and any red item that its row had proved
green is recorded as an escape. Records collected items' verdicts and
read-sets when record is true; an item that collected no tests
(exit code 5) writes no row.
Source code in packages/extensions/pytest/src/livery/extensions/pytest/_runner.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 | |
item_runner ¶
Answer python.test.item-runner with ci_item_runner.
ci_item_runner ¶
ci_item_runner(*pytest_args: str, dirs: tuple[str, ...], root: Path, env: Mapping[str, str], serial: bool = False, sums_file: Path | None = None) -> list[str]
Answer python.test.item-runner: run CI test items one process per file.
Returns a list of failure descriptions (empty when every item passed or collected no tests). Prints captured output for every red item so CI logs carry the full failure trace.
Source code in packages/extensions/pytest/src/livery/extensions/pytest/_runner.py
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 | |