Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#77 VS code workaround #78

Merged
merged 3 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/postStartCommand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ nohup bash -c '.devcontainer/postStartBackground.sh &' > .dev_container_logs/pos

docker compose -f tests/workarounds/pytest_django/docker-compose.yml up -d postgres

poetry run dmypy start
poetry run dmypy start || true
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive-by: fix error message when the dev container starts

8 changes: 8 additions & 0 deletions .ptyme_track/JamesHutchison
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,11 @@
{"time": "2024-01-03 23:36:35", "signed_time": {"server_id": "1eb67bdb-d0bd-48b0-a532-51701e956a47", "time": "2024-01-03 23:36:35", "sig": "ad9472a8dc4c108574abe39513f918aa17fedbfa7ebfb6cd749021b65c9b3cf5"}, "hash": "9f5dcc23a22776cded24ff35194a7717", "stop": false, "git-branch": "restore-logging-colors"}
{"time": "2024-01-03 23:38:33", "signed_time": {"server_id": "1eb67bdb-d0bd-48b0-a532-51701e956a47", "time": "2024-01-03 23:38:33", "sig": "42679bf9908cf890e66de814740af7773126261d1fdc5a72aa7abdef30a05ab7"}, "hash": "123ccc9fb6ab256f282e488e69a51d80", "stop": false, "git-branch": "restore-logging-colors"}
{"time": "2024-01-03 23:40:33", "signed_time": {"server_id": "1eb67bdb-d0bd-48b0-a532-51701e956a47", "time": "2024-01-03 23:40:33", "sig": "7dca698152abf42cd036f3ee6ec673f749adafccf5eb2234140212494757c3d9"}, "hash": "123ccc9fb6ab256f282e488e69a51d80", "stop": true, "git-branch": "restore-logging-colors"}
{"time": "2024-01-03 23:46:34", "signed_time": {"server_id": "1eb67bdb-d0bd-48b0-a532-51701e956a47", "time": "2024-01-03 23:46:34", "sig": "6f88c8f6d078e9376f00a78e9125de8e1b4ac58b3e6f07f5b5d1357870767066"}, "hash": "daf6e7098a87e08c887af903a37f47dc", "stop": false, "git-branch": "vs-code-workaround"}
{"time": "2024-01-03 23:48:34", "signed_time": {"server_id": "1eb67bdb-d0bd-48b0-a532-51701e956a47", "time": "2024-01-03 23:48:34", "sig": "88b9d34a9333dd7db04df66cb43801dc75e7fd05c4e7d7476c764412fec13554"}, "hash": "daf6e7098a87e08c887af903a37f47dc", "stop": true, "git-branch": "vs-code-workaround"}
{"time": "2024-01-05 06:48:16", "signed_time": {"server_id": "4121c46a-3c83-4268-add3-cdd854937fe3", "time": "2024-01-05 06:48:16", "sig": "1906c2bbb0655e40d24db2350f4a5d72a416fd7a0bfd72bbe8eea1b63cb56d7a"}, "hash": "daf6e7098a87e08c887af903a37f47dc", "stop": false, "git-branch": "vs-code-workaround"}
{"time": "2024-01-05 06:50:16", "signed_time": {"server_id": "4121c46a-3c83-4268-add3-cdd854937fe3", "time": "2024-01-05 06:50:16", "sig": "e8169a941bcb3325621b9de13c935037edc164cef6ded38233e2bd977aba7838"}, "hash": "daf6e7098a87e08c887af903a37f47dc", "stop": true, "git-branch": "vs-code-workaround"}
{"time": "2024-01-05 06:52:15", "signed_time": {"server_id": "4121c46a-3c83-4268-add3-cdd854937fe3", "time": "2024-01-05 06:52:15", "sig": "aa9512c91435ce7bbc6c44c674795f2c84205d513656ca01ba2ab2a76b8bb422"}, "hash": "29f6df229c939062c0eab91fe035b3d7", "stop": false, "git-branch": "vs-code-workaround"}
{"time": "2024-01-05 06:54:15", "signed_time": {"server_id": "4121c46a-3c83-4268-add3-cdd854937fe3", "time": "2024-01-05 06:54:15", "sig": "6a7f9f346ab77ddcd09ec4041c8de9f1d80db4b641accbb74b2e90e5f622ed30"}, "hash": "29f6df229c939062c0eab91fe035b3d7", "stop": true, "git-branch": "vs-code-workaround"}
{"time": "2024-01-05 07:00:16", "signed_time": {"server_id": "4121c46a-3c83-4268-add3-cdd854937fe3", "time": "2024-01-05 07:00:16", "sig": "b7fa60e7fc239eb5babbaa3205f7355c6537d27a22abd7d6466007265cadce6c"}, "hash": "e0950f040c2c9be37b4b16cbe7c45daf", "stop": false, "git-branch": "vs-code-workaround"}
{"time": "2024-01-05 07:00:55", "signed_time": {"server_id": "dfe2bbb2-ff98-43e0-8691-a8c45d2bfec2", "time": "2024-01-05 07:00:55", "sig": "1af42c1937070f7b691a38a32e39902a320ea84dfecbe7b4d303d1ae0ff4c5c1"}, "hash": "e0950f040c2c9be37b4b16cbe7c45daf", "stop": false, "git-branch": "vs-code-workaround"}
22 changes: 22 additions & 0 deletions pytest_hot_reloading/workarounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ def pytest_django_tox_workaround() -> None:
fixtures._set_suffix_to_test_databases = lambda suffix: None


@register_workaround("vscode_pytest")
def vscode_pytest_workaround() -> None:
"""
VS Code seems to keep track of collected tests and does a check to ensure
they were not already collected before returning them.

Also, it uses a list when all it does is an existence check, so this swaps
the list for a set with `append`.
"""

import vscode_pytest # type: ignore

class SetWithAppendRemove(set):
def append(self, val) -> None:
self.add(val)

def remove(self, val) -> None:
self.remove(val)

vscode_pytest.collected_tests_so_far = SetWithAppendRemove()


def run_workarounds_pre() -> list[Generator]:
in_progress_workarounds = []
for module_name, workaround in workarounds:
Expand Down