Test that location information is correct.
()
| 340 | |
| 341 | |
| 342 | def test_sarif_location_info(): |
| 343 | """Test that location information is correct.""" |
| 344 | sarif = run_sarif_check(BASIC_TEST_CODE) |
| 345 | |
| 346 | run = sarif["runs"][0] |
| 347 | results = run["results"] |
| 348 | |
| 349 | for result in results: |
| 350 | assert "locations" in result |
| 351 | locations = result["locations"] |
| 352 | assert len(locations) > 0 |
| 353 | |
| 354 | for location in locations: |
| 355 | assert "physicalLocation" in location |
| 356 | phys_loc = location["physicalLocation"] |
| 357 | |
| 358 | assert "artifactLocation" in phys_loc |
| 359 | assert "uri" in phys_loc["artifactLocation"] |
| 360 | |
| 361 | assert "region" in phys_loc |
| 362 | region = phys_loc["region"] |
| 363 | |
| 364 | # SARIF requires line and column numbers >= 1 |
| 365 | assert "startLine" in region |
| 366 | assert region["startLine"] >= 1 |
| 367 | |
| 368 | assert "startColumn" in region |
| 369 | assert region["startColumn"] >= 1 |
| 370 | |
| 371 | |
| 372 | def test_sarif_with_multiple_files(tmp_path): |
nothing calls this directly
no test coverage detected