Skip to content

Commit

Permalink
fix fastapi app path to module conversion on Windows (#5858)
Browse files Browse the repository at this point in the history
### Summary

- addresses #5312
- re-enables `Python - Verify Basic FastAPI App [C903306]` on Windows

### Release Notes

#### New Features

- N/A

#### Bug Fixes

- Fixes bug in file path to module import path conversion in the Python
Extension, which was preventing FastAPI apps from running on Windows
when using the App Launcher (#5312)

### QA Notes

Running
[fastapi_example.py](https://github.com/posit-dev/qa-example-content/blob/main/workspaces/python_apps/fastapi_example/fastapi_example.py)
with the App Launcher should now work on Windows.

#### PR Testing

@:apps

Windows Test Results 🎉 

- test run:
https://github.com/posit-dev/positron/actions/runs/12486724958/job/34847131287

<img width="987" alt="image"
src="https://github.com/user-attachments/assets/ddb9c59a-509c-496e-a7f0-eb961a4359b8"
/>
  • Loading branch information
sharon-wang authored Jan 8, 2025
1 parent 8d2adc8 commit f576f53
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@ function pathToModule(p: string): string {
}

// Otherwise, convert the path to a Python module format.
const parts = relativeDir.split(path.sep);

const parts = relativeDir.split(/[/\\]/);
return parts.concat(mod).join('.');
}

Expand Down
4 changes: 3 additions & 1 deletion test/e2e/tests/apps/python-apps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ test.describe('Python Applications', {
});
});

test('Python - Verify Basic FastAPI App [C903306]', async function ({ app, python }) {
test('Python - Verify Basic FastAPI App [C903306]', {
tag: [tags.WIN]
}, async function ({ app, python }) {
const viewer = app.workbench.viewer;

await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'workspaces', 'python_apps', 'fastapi_example', 'fastapi_example.py'));
Expand Down

0 comments on commit f576f53

Please sign in to comment.