|
1870 | 1870 | ], |
1871 | 1871 | "id_": TEST_DATA_PATH_STR, |
1872 | 1872 | } |
| 1873 | + |
| 1874 | +# ===================================================================================== |
| 1875 | +# PROJECT_ROOT_PATH environment variable tests |
| 1876 | +# These test the project-based testing feature where PROJECT_ROOT_PATH changes |
| 1877 | +# the test tree root from cwd to the specified project path. |
| 1878 | +# ===================================================================================== |
| 1879 | + |
| 1880 | +# This is the expected output for unittest_folder when PROJECT_ROOT_PATH is set to unittest_folder. |
| 1881 | +# The root of the tree is unittest_folder (not .data), simulating project-based testing. |
| 1882 | +# |
| 1883 | +# **Project Configuration:** |
| 1884 | +# In the VS Code Python extension, projects are defined by the Python Environments extension. |
| 1885 | +# Each project has a root directory (identified by pyproject.toml, setup.py, etc.). |
| 1886 | +# When PROJECT_ROOT_PATH is set, pytest uses that path as the test tree root instead of cwd. |
| 1887 | +# |
| 1888 | +# **Test Tree Structure:** |
| 1889 | +# Without PROJECT_ROOT_PATH (legacy mode): |
| 1890 | +# └── .data (cwd = workspace root) |
| 1891 | +# └── unittest_folder |
| 1892 | +# └── test_add.py, test_subtract.py... |
| 1893 | +# |
| 1894 | +# With PROJECT_ROOT_PATH set to unittest_folder (project-based mode): |
| 1895 | +# └── unittest_folder (ROOT - set via PROJECT_ROOT_PATH env var) |
| 1896 | +# ├── test_add.py |
| 1897 | +# │ └── TestAddFunction |
| 1898 | +# │ ├── test_add_negative_numbers |
| 1899 | +# │ └── test_add_positive_numbers |
| 1900 | +# │ └── TestDuplicateFunction |
| 1901 | +# │ └── test_dup_a |
| 1902 | +# └── test_subtract.py |
| 1903 | +# └── TestSubtractFunction |
| 1904 | +# ├── test_subtract_negative_numbers |
| 1905 | +# └── test_subtract_positive_numbers |
| 1906 | +# └── TestDuplicateFunction |
| 1907 | +# └── test_dup_s |
| 1908 | +# |
| 1909 | +# Note: This reuses the unittest_folder paths defined earlier in this file. |
| 1910 | +project_root_unittest_folder_expected_output = { |
| 1911 | + "name": "unittest_folder", |
| 1912 | + "path": os.fspath(unittest_folder_path), |
| 1913 | + "type_": "folder", |
| 1914 | + "children": [ |
| 1915 | + { |
| 1916 | + "name": "test_add.py", |
| 1917 | + "path": os.fspath(test_add_path), |
| 1918 | + "type_": "file", |
| 1919 | + "id_": os.fspath(test_add_path), |
| 1920 | + "children": [ |
| 1921 | + { |
| 1922 | + "name": "TestAddFunction", |
| 1923 | + "path": os.fspath(test_add_path), |
| 1924 | + "type_": "class", |
| 1925 | + "children": [ |
| 1926 | + { |
| 1927 | + "name": "test_add_negative_numbers", |
| 1928 | + "path": os.fspath(test_add_path), |
| 1929 | + "lineno": find_test_line_number( |
| 1930 | + "test_add_negative_numbers", |
| 1931 | + os.fspath(test_add_path), |
| 1932 | + ), |
| 1933 | + "type_": "test", |
| 1934 | + "id_": get_absolute_test_id( |
| 1935 | + "test_add.py::TestAddFunction::test_add_negative_numbers", |
| 1936 | + test_add_path, |
| 1937 | + ), |
| 1938 | + "runID": get_absolute_test_id( |
| 1939 | + "test_add.py::TestAddFunction::test_add_negative_numbers", |
| 1940 | + test_add_path, |
| 1941 | + ), |
| 1942 | + }, |
| 1943 | + { |
| 1944 | + "name": "test_add_positive_numbers", |
| 1945 | + "path": os.fspath(test_add_path), |
| 1946 | + "lineno": find_test_line_number( |
| 1947 | + "test_add_positive_numbers", |
| 1948 | + os.fspath(test_add_path), |
| 1949 | + ), |
| 1950 | + "type_": "test", |
| 1951 | + "id_": get_absolute_test_id( |
| 1952 | + "test_add.py::TestAddFunction::test_add_positive_numbers", |
| 1953 | + test_add_path, |
| 1954 | + ), |
| 1955 | + "runID": get_absolute_test_id( |
| 1956 | + "test_add.py::TestAddFunction::test_add_positive_numbers", |
| 1957 | + test_add_path, |
| 1958 | + ), |
| 1959 | + }, |
| 1960 | + ], |
| 1961 | + "id_": get_absolute_test_id( |
| 1962 | + "test_add.py::TestAddFunction", |
| 1963 | + test_add_path, |
| 1964 | + ), |
| 1965 | + "lineno": find_class_line_number("TestAddFunction", test_add_path), |
| 1966 | + }, |
| 1967 | + { |
| 1968 | + "name": "TestDuplicateFunction", |
| 1969 | + "path": os.fspath(test_add_path), |
| 1970 | + "type_": "class", |
| 1971 | + "children": [ |
| 1972 | + { |
| 1973 | + "name": "test_dup_a", |
| 1974 | + "path": os.fspath(test_add_path), |
| 1975 | + "lineno": find_test_line_number( |
| 1976 | + "test_dup_a", |
| 1977 | + os.fspath(test_add_path), |
| 1978 | + ), |
| 1979 | + "type_": "test", |
| 1980 | + "id_": get_absolute_test_id( |
| 1981 | + "test_add.py::TestDuplicateFunction::test_dup_a", |
| 1982 | + test_add_path, |
| 1983 | + ), |
| 1984 | + "runID": get_absolute_test_id( |
| 1985 | + "test_add.py::TestDuplicateFunction::test_dup_a", |
| 1986 | + test_add_path, |
| 1987 | + ), |
| 1988 | + }, |
| 1989 | + ], |
| 1990 | + "id_": get_absolute_test_id( |
| 1991 | + "test_add.py::TestDuplicateFunction", |
| 1992 | + test_add_path, |
| 1993 | + ), |
| 1994 | + "lineno": find_class_line_number("TestDuplicateFunction", test_add_path), |
| 1995 | + }, |
| 1996 | + ], |
| 1997 | + }, |
| 1998 | + { |
| 1999 | + "name": "test_subtract.py", |
| 2000 | + "path": os.fspath(test_subtract_path), |
| 2001 | + "type_": "file", |
| 2002 | + "id_": os.fspath(test_subtract_path), |
| 2003 | + "children": [ |
| 2004 | + { |
| 2005 | + "name": "TestSubtractFunction", |
| 2006 | + "path": os.fspath(test_subtract_path), |
| 2007 | + "type_": "class", |
| 2008 | + "children": [ |
| 2009 | + { |
| 2010 | + "name": "test_subtract_negative_numbers", |
| 2011 | + "path": os.fspath(test_subtract_path), |
| 2012 | + "lineno": find_test_line_number( |
| 2013 | + "test_subtract_negative_numbers", |
| 2014 | + os.fspath(test_subtract_path), |
| 2015 | + ), |
| 2016 | + "type_": "test", |
| 2017 | + "id_": get_absolute_test_id( |
| 2018 | + "test_subtract.py::TestSubtractFunction::test_subtract_negative_numbers", |
| 2019 | + test_subtract_path, |
| 2020 | + ), |
| 2021 | + "runID": get_absolute_test_id( |
| 2022 | + "test_subtract.py::TestSubtractFunction::test_subtract_negative_numbers", |
| 2023 | + test_subtract_path, |
| 2024 | + ), |
| 2025 | + }, |
| 2026 | + { |
| 2027 | + "name": "test_subtract_positive_numbers", |
| 2028 | + "path": os.fspath(test_subtract_path), |
| 2029 | + "lineno": find_test_line_number( |
| 2030 | + "test_subtract_positive_numbers", |
| 2031 | + os.fspath(test_subtract_path), |
| 2032 | + ), |
| 2033 | + "type_": "test", |
| 2034 | + "id_": get_absolute_test_id( |
| 2035 | + "test_subtract.py::TestSubtractFunction::test_subtract_positive_numbers", |
| 2036 | + test_subtract_path, |
| 2037 | + ), |
| 2038 | + "runID": get_absolute_test_id( |
| 2039 | + "test_subtract.py::TestSubtractFunction::test_subtract_positive_numbers", |
| 2040 | + test_subtract_path, |
| 2041 | + ), |
| 2042 | + }, |
| 2043 | + ], |
| 2044 | + "id_": get_absolute_test_id( |
| 2045 | + "test_subtract.py::TestSubtractFunction", |
| 2046 | + test_subtract_path, |
| 2047 | + ), |
| 2048 | + "lineno": find_class_line_number("TestSubtractFunction", test_subtract_path), |
| 2049 | + }, |
| 2050 | + { |
| 2051 | + "name": "TestDuplicateFunction", |
| 2052 | + "path": os.fspath(test_subtract_path), |
| 2053 | + "type_": "class", |
| 2054 | + "children": [ |
| 2055 | + { |
| 2056 | + "name": "test_dup_s", |
| 2057 | + "path": os.fspath(test_subtract_path), |
| 2058 | + "lineno": find_test_line_number( |
| 2059 | + "test_dup_s", |
| 2060 | + os.fspath(test_subtract_path), |
| 2061 | + ), |
| 2062 | + "type_": "test", |
| 2063 | + "id_": get_absolute_test_id( |
| 2064 | + "test_subtract.py::TestDuplicateFunction::test_dup_s", |
| 2065 | + test_subtract_path, |
| 2066 | + ), |
| 2067 | + "runID": get_absolute_test_id( |
| 2068 | + "test_subtract.py::TestDuplicateFunction::test_dup_s", |
| 2069 | + test_subtract_path, |
| 2070 | + ), |
| 2071 | + }, |
| 2072 | + ], |
| 2073 | + "id_": get_absolute_test_id( |
| 2074 | + "test_subtract.py::TestDuplicateFunction", |
| 2075 | + test_subtract_path, |
| 2076 | + ), |
| 2077 | + "lineno": find_class_line_number("TestDuplicateFunction", test_subtract_path), |
| 2078 | + }, |
| 2079 | + ], |
| 2080 | + }, |
| 2081 | + ], |
| 2082 | + "id_": os.fspath(unittest_folder_path), |
| 2083 | +} |
0 commit comments