Skip to content

Commit ab7bfb5

Browse files
Change exclusion syntax from ./tests to tests/*
Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
1 parent 912e650 commit ab7bfb5

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/usethis/_integrations/sonarqube/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def get_sonar_project_properties() -> str: # noqa: PLR0912
7979
if source_dir_str == ".":
8080
sources = "./"
8181
# When using flat layout, exclude tests directory to avoid double indexing
82-
if "./tests" not in exclusions:
83-
exclusions.insert(0, "./tests")
82+
if "tests/*" not in exclusions:
83+
exclusions.insert(0, "tests/*")
8484
else:
8585
sources = f"./{source_dir_str}"
8686

tests/usethis/_integrations/sonarqube/test_sonarqube_config.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_different_python_version(self, tmp_path: Path):
100100
sonar.tests=./tests
101101
sonar.python.coverage.reportPaths=coverage.xml
102102
sonar.verbose=false
103-
sonar.exclusions=./tests
103+
sonar.exclusions=tests/*
104104
"""
105105
)
106106

@@ -129,7 +129,7 @@ def test_no_pin_python(self, tmp_path: Path):
129129
sonar.tests=./tests
130130
sonar.python.coverage.reportPaths=coverage.xml
131131
sonar.verbose=false
132-
sonar.exclusions=./tests
132+
sonar.exclusions=tests/*
133133
"""
134134
)
135135

@@ -159,7 +159,7 @@ def test_different_project_key(self, tmp_path: Path):
159159
sonar.tests=./tests
160160
sonar.python.coverage.reportPaths=coverage.xml
161161
sonar.verbose=false
162-
sonar.exclusions=./tests
162+
sonar.exclusions=tests/*
163163
"""
164164
)
165165

@@ -192,7 +192,7 @@ def test_set_verbose_true(self, tmp_path: Path):
192192
sonar.tests=./tests
193193
sonar.python.coverage.reportPaths=coverage.xml
194194
sonar.verbose=true
195-
sonar.exclusions=./tests
195+
sonar.exclusions=tests/*
196196
"""
197197
)
198198

@@ -239,7 +239,7 @@ def test_patch_version_ignored(self, tmp_path: Path):
239239
sonar.tests=./tests
240240
sonar.python.coverage.reportPaths=coverage.xml
241241
sonar.verbose=false
242-
sonar.exclusions=./tests
242+
sonar.exclusions=tests/*
243243
"""
244244
)
245245

@@ -276,7 +276,7 @@ def test_exclusions(self, tmp_path: Path):
276276
sonar.tests=./tests
277277
sonar.python.coverage.reportPaths=coverage.xml
278278
sonar.verbose=false
279-
sonar.exclusions=./tests, **/Dockerfile, src/notebooks/**/*
279+
sonar.exclusions=tests/*, **/Dockerfile, src/notebooks/**/*
280280
"""
281281
)
282282

@@ -307,7 +307,7 @@ def test_different_coverage_file_location(self, tmp_path: Path):
307307
sonar.tests=./tests
308308
sonar.python.coverage.reportPaths=./test-reports/cov.xml
309309
sonar.verbose=false
310-
sonar.exclusions=./tests
310+
sonar.exclusions=tests/*
311311
"""
312312
)
313313

@@ -325,7 +325,7 @@ def test_missing_coverage_file_location_error(self, tmp_path: Path):
325325
get_sonar_project_properties()
326326

327327
def test_flat_layout_exclusions_already_has_tests(self, tmp_path: Path):
328-
# When using flat layout and ./tests is already in exclusions,
328+
# When using flat layout and tests/* is already in exclusions,
329329
# it should not be added again.
330330

331331
with change_cwd(tmp_path), PyprojectTOMLManager():
@@ -337,7 +337,7 @@ def test_flat_layout_exclusions_already_has_tests(self, tmp_path: Path):
337337
)
338338
PyprojectTOMLManager().set_value(
339339
keys=["tool", "usethis", "sonarqube", "exclusions"],
340-
value=["./tests", "**/Dockerfile"],
340+
value=["tests/*", "**/Dockerfile"],
341341
)
342342
PyprojectTOMLManager().set_value(
343343
keys=["tool", "coverage", "xml", "output"], value="coverage.xml"
@@ -357,7 +357,7 @@ def test_flat_layout_exclusions_already_has_tests(self, tmp_path: Path):
357357
sonar.tests=./tests
358358
sonar.python.coverage.reportPaths=coverage.xml
359359
sonar.verbose=false
360-
sonar.exclusions=./tests, **/Dockerfile
360+
sonar.exclusions=tests/*, **/Dockerfile
361361
"""
362362
)
363363

0 commit comments

Comments
 (0)