| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1308730 commit f77a011
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,3 +19,11 @@ def test_add_positive_numbers(self): # test_marker--test_add_positive_numbers | |||
| 19 | 19 | def test_add_negative_numbers(self): # test_marker--test_add_negative_numbers | |
| 20 | 20 | result = add(-2, -3) | |
| 21 | 21 | self.assertEqual(result, -5) | |
| 22 | + | ||
| 23 | + | ||
| 24 | + class TestDuplicateFunction(unittest.TestCase): | ||
| 25 | + # This test's id is unittest_folder/test_subtract.py::TestDuplicateFunction::test_dup_a. It has the same class name as | ||
| 26 | + # another test, but it's in a different file, so it should not be confused. | ||
| 27 | + # This test passes. | ||
| 28 | + def test_dup_a(self): # test_marker--test_dup_a | ||
| 29 | + self.assertEqual(1, 1) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,3 +24,11 @@ def test_subtract_negative_numbers( # test_marker--test_subtract_negative_numbe | |||
| 24 | 24 | result = subtract(-2, -3) | |
| 25 | 25 | # This is intentional to test assertion failures | |
| 26 | 26 | self.assertEqual(result, 100000) | |
| 27 | + | ||
| 28 | + | ||
| 29 | + class TestDuplicateFunction(unittest.TestCase): | ||
| 30 | + # This test's id is unittest_folder/test_subtract.py::TestDuplicateFunction::test_dup_s. It has the same class name as | ||
| 31 | + # another test, but it's in a different file, so it should not be confused. | ||
| 32 | + # This test passes. | ||
| 33 | + def test_dup_s(self): # test_marker--test_dup_s | ||
| 34 | + self.assertEqual(1, 1) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -106,10 +106,14 @@ | |||
| 106 | 106 | # │ └── TestAddFunction | |
| 107 | 107 | # │ ├── test_add_negative_numbers | |
| 108 | 108 | # │ └── test_add_positive_numbers | |
| 109 | + # │ └── TestDuplicateFunction | ||
| 110 | + # │ └── test_dup_a | ||
| 109 | 111 | # └── test_subtract.py | |
| 110 | 112 | # └── TestSubtractFunction | |
| 111 | 113 | # ├── test_subtract_negative_numbers | |
| 112 | 114 | # └── test_subtract_positive_numbers | |
| 115 | + # │ └── TestDuplicateFunction | ||
| 116 | + # │ └── test_dup_s | ||
| 113 | 117 | unittest_folder_path = os.fspath(TEST_DATA_PATH / "unittest_folder") | |
| 114 | 118 | test_add_path = os.fspath(TEST_DATA_PATH / "unittest_folder" / "test_add.py") | |
| 115 | 119 | test_subtract_path = os.fspath(TEST_DATA_PATH / "unittest_folder" / "test_subtract.py") | |
@@ -159,7 +163,26 @@ | |||
| 159 | 163 | }, | |
| 160 | 164 | ], | |
| 161 | 165 | "id_": "unittest_folder/test_add.py::TestAddFunction", | |
| 162 | - } | ||
| 166 | + }, | ||
| 167 | + { | ||
| 168 | + "name": "TestDuplicateFunction", | ||
| 169 | + "path": test_add_path, | ||
| 170 | + "type_": "class", | ||
| 171 | + "children": [ | ||
| 172 | + { | ||
| 173 | + "name": "test_dup_a", | ||
| 174 | + "path": test_add_path, | ||
| 175 | + "lineno": find_test_line_number( | ||
| 176 | + "test_dup_a", | ||
| 177 | + test_add_path, | ||
| 178 | + ), | ||
| 179 | + "type_": "test", | ||
| 180 | + "id_": "unittest_folder/test_add.py::TestDuplicateFunction::test_dup_a", | ||
| 181 | + "runID": "unittest_folder/test_add.py::TestDuplicateFunction::test_dup_a", | ||
| 182 | + }, | ||
| 183 | + ], | ||
| 184 | + "id_": "unittest_folder/test_add.py::TestDuplicateFunction", | ||
| 185 | + }, | ||
| 163 | 186 | ], | |
| 164 | 187 | }, | |
| 165 | 188 | { | |
@@ -197,7 +220,26 @@ | |||
| 197 | 220 | }, | |
| 198 | 221 | ], | |
| 199 | 222 | "id_": "unittest_folder/test_subtract.py::TestSubtractFunction", | |
| 200 | - } | ||
| 223 | + }, | ||
| 224 | + { | ||
| 225 | + "name": "TestDuplicateFunction", | ||
| 226 | + "path": test_subtract_path, | ||
| 227 | + "type_": "class", | ||
| 228 | + "children": [ | ||
| 229 | + { | ||
| 230 | + "name": "test_dup_s", | ||
| 231 | + "path": test_subtract_path, | ||
| 232 | + "lineno": find_test_line_number( | ||
| 233 | + "test_dup_s", | ||
| 234 | + test_subtract_path, | ||
| 235 | + ), | ||
| 236 | + "type_": "test", | ||
| 237 | + "id_": "unittest_folder/test_subtract.py::TestDuplicateFunction::test_dup_s", | ||
| 238 | + "runID": "unittest_folder/test_subtract.py::TestDuplicateFunction::test_dup_s", | ||
| 239 | + }, | ||
| 240 | + ], | ||
| 241 | + "id_": "unittest_folder/test_subtract.py::TestDuplicateFunction", | ||
| 242 | + }, | ||
| 201 | 243 | ], | |
| 202 | 244 | }, | |
| 203 | 245 | ], | |
@@ -206,6 +248,7 @@ | |||
| 206 | 248 | "id_": TEST_DATA_PATH_STR, | |
| 207 | 249 | } | |
| 208 | 250 | ||
| 251 | + | ||
| 209 | 252 | # This is the expected output for the dual_level_nested_folder tests | |
| 210 | 253 | # └── dual_level_nested_folder | |
| 211 | 254 | # └── test_top_folder.py | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -266,10 +266,10 @@ def build_test_tree(session: pytest.Session) -> TestNode: | |||
| 266 | 266 | test_node = create_test_node(test_case) | |
| 267 | 267 | if isinstance(test_case.parent, pytest.Class): | |
| 268 | 268 | try: | |
| 269 | - test_class_node = class_nodes_dict[test_case.parent.name] | ||
| 269 | + test_class_node = class_nodes_dict[test_case.parent.nodeid] | ||
| 270 | 270 | except KeyError: | |
| 271 | 271 | test_class_node = create_class_node(test_case.parent) | |
| 272 | - class_nodes_dict[test_case.parent.name] = test_class_node | ||
| 272 | + class_nodes_dict[test_case.parent.nodeid] = test_class_node | ||
| 273 | 273 | test_class_node["children"].append(test_node) | |
| 274 | 274 | if test_case.parent.parent: | |
| 275 | 275 | parent_module = test_case.parent.parent | |
| Back | FazBrowse Home | New Git URL |
0 commit comments