Title: agent: avoid creating filesystem directories with OS-special names in tests · Issue #1906 · usethis-python/usethis-python · GitHub
Open Graph Title: agent: avoid creating filesystem directories with OS-special names in tests · Issue #1906 · usethis-python/usethis-python
X Title: agent: avoid creating filesystem directories with OS-special names in tests · Issue #1906 · usethis-python/usethis-python
Description: What happened A test that created a directory named "..." via path.mkdir() failed on Windows CI. On Windows, "..." is interpreted as parent directory traversal (../..), so mkdir() raised FileExistsError because the resolved path already ...
Open Graph Description: What happened A test that created a directory named "..." via path.mkdir() failed on Windows CI. On Windows, "..." is interpreted as parent directory traversal (../..), so mkdir() raised FileExists...
X Description: What happened A test that created a directory named "..." via path.mkdir() failed on Windows CI. On Windows, "..." is interpreted as parent directory traversal (../..), so mkdir...
Opengraph URL: https://github.com/usethis-python/usethis-python/issues/1906
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"agent: avoid creating filesystem directories with OS-special names in tests","articleBody":"## What happened\n\nA test that created a directory named `\"...\"` via `path.mkdir()` failed on Windows CI. On Windows, `\"...\"` is interpreted as parent directory traversal (`../..`), so `mkdir()` raised `FileExistsError` because the resolved path already existed. Similarly, directory names like `\"project.\"` (trailing dot) are silently stripped by Windows, leading to unexpected behaviour.\n\n## Root cause\n\nThe test created real filesystem directories to test a pure string-processing function (`get_project_name_from_dir()`). The function only reads the `.name` attribute of a `Path` object and never accesses the filesystem. By unnecessarily coupling the test to real directory creation, the test became sensitive to OS-specific path normalisation rules that are irrelevant to the logic under test.\n\n## Generalised principle\n\nWhen testing pure logic that only inspects path metadata (e.g. `.name`, `.suffix`, `.parent`) without touching the filesystem, use synthetic `Path` or `PurePosixPath` objects instead of creating real directories. This avoids cross-platform failures caused by OS-specific path restrictions — especially on Windows, where certain characters and patterns (leading/trailing dots, reserved names like `CON`, `NUL`, etc.) are invalid or silently normalised in real paths.\n\n## Recommended action\n\n- **Skill update:** Update the `usethis-python-test` skill to include guidance: \"When the code under test only reads path metadata (`.name`, `.suffix`, `.parent`) and does not access the filesystem, prefer `PurePosixPath` or direct `usethis_config.set(project_dir=...)` with synthetic paths instead of creating real directories. This avoids Windows-specific path restrictions causing test failures.\"\n- Scan the codebase for violations of this principle and fix","author":{"url":"https://github.com/nathanjmcdougall","@type":"Person","name":"nathanjmcdougall"},"datePublished":"2026-04-09T07:33:49.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1906/usethis-python/issues/1906"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5a6ad09a-b1fd-a6ec-0252-fee8e0ad53f7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9546:17FA4:28D853:3818B4:6A4D99BA |
| html-safe-nonce | 836daaa3b5e42d6bcfafed01de79fb94b3059dc8049632c2fceddd3870272611 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTQ2OjE3RkE0OjI4RDg1MzozODE4QjQ6NkE0RDk5QkEiLCJ2aXNpdG9yX2lkIjoiMjY4MzU2MjA1NDQxODAxMjYwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | db4b3e4b8ea498920f4ecd2c27a5c1e96dd56fe64b8a98e3ac5e249afcc8eb93 |
| hovercard-subject-tag | issue:4230360768 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/usethis-python/usethis-python/1906/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1f59db93c09008dcf6cbadc14637871e11daa3d8aebdc6c5cb9169749b42b0ec/usethis-python/usethis-python/issues/1906 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1f59db93c09008dcf6cbadc14637871e11daa3d8aebdc6c5cb9169749b42b0ec/usethis-python/usethis-python/issues/1906 |
| og:image:alt | What happened A test that created a directory named "..." via path.mkdir() failed on Windows CI. On Windows, "..." is interpreted as parent directory traversal (../..), so mkdir() raised FileExists... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nathanjmcdougall |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/usethis-python/usethis-python git https://github.com/usethis-python/usethis-python.git |
| octolytics-dimension-user_id | 216362695 |
| octolytics-dimension-user_login | usethis-python |
| octolytics-dimension-repository_id | 842189705 |
| octolytics-dimension-repository_nwo | usethis-python/usethis-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 842189705 |
| octolytics-dimension-repository_network_root_nwo | usethis-python/usethis-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a7b5592971a4eafa6614134ea168f0d03716b98d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width