|
2013 | 2013 | ], |
2014 | 2014 | "id_": TEST_DATA_PATH_STR, |
2015 | 2015 | } |
| 2016 | + |
| 2017 | +# ===================================================================================== |
| 2018 | +# PROJECT_ROOT_PATH environment variable tests |
| 2019 | +# These test the project-based testing feature where PROJECT_ROOT_PATH changes |
| 2020 | +# the test tree root from cwd to the specified project path. |
| 2021 | +# ===================================================================================== |
| 2022 | + |
| 2023 | +# This is the expected output for unittest_folder when PROJECT_ROOT_PATH is set to unittest_folder. |
| 2024 | +# The root of the tree is unittest_folder (not .data), simulating project-based testing. |
| 2025 | +# |
| 2026 | +# **Project Configuration:** |
| 2027 | +# In the VS Code Python extension, projects are defined by the Python Environments extension. |
| 2028 | +# Each project has a root directory (identified by pyproject.toml, setup.py, etc.). |
| 2029 | +# When PROJECT_ROOT_PATH is set, pytest uses that path as the test tree root instead of cwd. |
| 2030 | +# |
| 2031 | +# **Test Tree Structure:** |
| 2032 | +# Without PROJECT_ROOT_PATH (legacy mode): |
| 2033 | +# └── .data (cwd = workspace root) |
| 2034 | +# └── unittest_folder |
| 2035 | +# └── test_add.py, test_subtract.py... |
| 2036 | +# |
| 2037 | +# With PROJECT_ROOT_PATH set to unittest_folder (project-based mode): |
| 2038 | +# └── unittest_folder (ROOT - set via PROJECT_ROOT_PATH env var) |
| 2039 | +# ├── test_add.py |
| 2040 | +# │ └── TestAddFunction |
| 2041 | +# │ ├── test_add_negative_numbers |
| 2042 | +# │ └── test_add_positive_numbers |
| 2043 | +# │ └── TestDuplicateFunction |
| 2044 | +# │ └── test_dup_a |
| 2045 | +# └── test_subtract.py |
| 2046 | +# └── TestSubtractFunction |
| 2047 | +# ├── test_subtract_negative_numbers |
| 2048 | +# └── test_subtract_positive_numbers |
| 2049 | +# └── TestDuplicateFunction |
| 2050 | +# └── test_dup_s |
| 2051 | +# |
| 2052 | +# Note: This reuses the unittest_folder paths defined earlier in this file. |
| 2053 | +project_root_unittest_folder_expected_output = { |
| 2054 | + "name": "unittest_folder", |
| 2055 | + "path": os.fspath(unittest_folder_path), |
| 2056 | + "type_": "folder", |
| 2057 | + "children": [ |
| 2058 | + { |
| 2059 | + "name": "test_add.py", |
| 2060 | + "path": os.fspath(test_add_path), |
| 2061 | + "type_": "file", |
| 2062 | + "id_": os.fspath(test_add_path), |
| 2063 | + "children": [ |
| 2064 | + { |
| 2065 | + "name": "TestAddFunction", |
| 2066 | + "path": os.fspath(test_add_path), |
| 2067 | + "type_": "class", |
| 2068 | + "children": [ |
| 2069 | + { |
| 2070 | + "name": "test_add_negative_numbers", |
| 2071 | + "path": os.fspath(test_add_path), |
| 2072 | + "lineno": find_test_line_number( |
| 2073 | + "test_add_negative_numbers", |
| 2074 | + os.fspath(test_add_path), |
| 2075 | + ), |
| 2076 | + "type_": "test", |
| 2077 | + "id_": get_absolute_test_id( |
| 2078 | + "test_add.py::TestAddFunction::test_add_negative_numbers", |
| 2079 | + test_add_path, |
| 2080 | + ), |
| 2081 | + "runID": get_absolute_test_id( |
| 2082 | + "test_add.py::TestAddFunction::test_add_negative_numbers", |
| 2083 | + test_add_path, |
| 2084 | + ), |
| 2085 | + }, |
| 2086 | + { |
| 2087 | + "name": "test_add_positive_numbers", |
| 2088 | + "path": os.fspath(test_add_path), |
| 2089 | + "lineno": find_test_line_number( |
| 2090 | + "test_add_positive_numbers", |
| 2091 | + os.fspath(test_add_path), |
| 2092 | + ), |
| 2093 | + "type_": "test", |
| 2094 | + "id_": get_absolute_test_id( |
| 2095 | + "test_add.py::TestAddFunction::test_add_positive_numbers", |
| 2096 | + test_add_path, |
| 2097 | + ), |
| 2098 | + "runID": get_absolute_test_id( |
| 2099 | + "test_add.py::TestAddFunction::test_add_positive_numbers", |
| 2100 | + test_add_path, |
| 2101 | + ), |
| 2102 | + }, |
| 2103 | + ], |
| 2104 | + "id_": get_absolute_test_id( |
| 2105 | + "test_add.py::TestAddFunction", |
| 2106 | + test_add_path, |
| 2107 | + ), |
| 2108 | + "lineno": find_class_line_number("TestAddFunction", test_add_path), |
| 2109 | + }, |
| 2110 | + { |
| 2111 | + "name": "TestDuplicateFunction", |
| 2112 | + "path": os.fspath(test_add_path), |
| 2113 | + "type_": "class", |
| 2114 | + "children": [ |
| 2115 | + { |
| 2116 | + "name": "test_dup_a", |
| 2117 | + "path": os.fspath(test_add_path), |
| 2118 | + "lineno": find_test_line_number( |
| 2119 | + "test_dup_a", |
| 2120 | + os.fspath(test_add_path), |
| 2121 | + ), |
| 2122 | + "type_": "test", |
| 2123 | + "id_": get_absolute_test_id( |
| 2124 | + "test_add.py::TestDuplicateFunction::test_dup_a", |
| 2125 | + test_add_path, |
| 2126 | + ), |
| 2127 | + "runID": get_absolute_test_id( |
| 2128 | + "test_add.py::TestDuplicateFunction::test_dup_a", |
| 2129 | + test_add_path, |
| 2130 | + ), |
| 2131 | + }, |
| 2132 | + ], |
| 2133 | + "id_": get_absolute_test_id( |
| 2134 | + "test_add.py::TestDuplicateFunction", |
| 2135 | + test_add_path, |
| 2136 | + ), |
| 2137 | + "lineno": find_class_line_number("TestDuplicateFunction", test_add_path), |
| 2138 | + }, |
| 2139 | + ], |
| 2140 | + }, |
| 2141 | + { |
| 2142 | + "name": "test_subtract.py", |
| 2143 | + "path": os.fspath(test_subtract_path), |
| 2144 | + "type_": "file", |
| 2145 | + "id_": os.fspath(test_subtract_path), |
| 2146 | + "children": [ |
| 2147 | + { |
| 2148 | + "name": "TestSubtractFunction", |
| 2149 | + "path": os.fspath(test_subtract_path), |
| 2150 | + "type_": "class", |
| 2151 | + "children": [ |
| 2152 | + { |
| 2153 | + "name": "test_subtract_negative_numbers", |
| 2154 | + "path": os.fspath(test_subtract_path), |
| 2155 | + "lineno": find_test_line_number( |
| 2156 | + "test_subtract_negative_numbers", |
| 2157 | + os.fspath(test_subtract_path), |
| 2158 | + ), |
| 2159 | + "type_": "test", |
| 2160 | + "id_": get_absolute_test_id( |
| 2161 | + "test_subtract.py::TestSubtractFunction::test_subtract_negative_numbers", |
| 2162 | + test_subtract_path, |
| 2163 | + ), |
| 2164 | + "runID": get_absolute_test_id( |
| 2165 | + "test_subtract.py::TestSubtractFunction::test_subtract_negative_numbers", |
| 2166 | + test_subtract_path, |
| 2167 | + ), |
| 2168 | + }, |
| 2169 | + { |
| 2170 | + "name": "test_subtract_positive_numbers", |
| 2171 | + "path": os.fspath(test_subtract_path), |
| 2172 | + "lineno": find_test_line_number( |
| 2173 | + "test_subtract_positive_numbers", |
| 2174 | + os.fspath(test_subtract_path), |
| 2175 | + ), |
| 2176 | + "type_": "test", |
| 2177 | + "id_": get_absolute_test_id( |
| 2178 | + "test_subtract.py::TestSubtractFunction::test_subtract_positive_numbers", |
| 2179 | + test_subtract_path, |
| 2180 | + ), |
| 2181 | + "runID": get_absolute_test_id( |
| 2182 | + "test_subtract.py::TestSubtractFunction::test_subtract_positive_numbers", |
| 2183 | + test_subtract_path, |
| 2184 | + ), |
| 2185 | + }, |
| 2186 | + ], |
| 2187 | + "id_": get_absolute_test_id( |
| 2188 | + "test_subtract.py::TestSubtractFunction", |
| 2189 | + test_subtract_path, |
| 2190 | + ), |
| 2191 | + "lineno": find_class_line_number("TestSubtractFunction", test_subtract_path), |
| 2192 | + }, |
| 2193 | + { |
| 2194 | + "name": "TestDuplicateFunction", |
| 2195 | + "path": os.fspath(test_subtract_path), |
| 2196 | + "type_": "class", |
| 2197 | + "children": [ |
| 2198 | + { |
| 2199 | + "name": "test_dup_s", |
| 2200 | + "path": os.fspath(test_subtract_path), |
| 2201 | + "lineno": find_test_line_number( |
| 2202 | + "test_dup_s", |
| 2203 | + os.fspath(test_subtract_path), |
| 2204 | + ), |
| 2205 | + "type_": "test", |
| 2206 | + "id_": get_absolute_test_id( |
| 2207 | + "test_subtract.py::TestDuplicateFunction::test_dup_s", |
| 2208 | + test_subtract_path, |
| 2209 | + ), |
| 2210 | + "runID": get_absolute_test_id( |
| 2211 | + "test_subtract.py::TestDuplicateFunction::test_dup_s", |
| 2212 | + test_subtract_path, |
| 2213 | + ), |
| 2214 | + }, |
| 2215 | + ], |
| 2216 | + "id_": get_absolute_test_id( |
| 2217 | + "test_subtract.py::TestDuplicateFunction", |
| 2218 | + test_subtract_path, |
| 2219 | + ), |
| 2220 | + "lineno": find_class_line_number("TestDuplicateFunction", test_subtract_path), |
| 2221 | + }, |
| 2222 | + ], |
| 2223 | + }, |
| 2224 | + ], |
| 2225 | + "id_": os.fspath(unittest_folder_path), |
| 2226 | +} |
0 commit comments