Skip to content

Commit ccf98d2

Browse files
#77 VS code workaround (#78)
* Add VS Code workaround * Fix error message about postStartCommand
1 parent c3d3812 commit ccf98d2

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

.devcontainer/postStartCommand.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ nohup bash -c '.devcontainer/postStartBackground.sh &' > .dev_container_logs/pos
55

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

8-
poetry run dmypy start
8+
poetry run dmypy start || true

.ptyme_track/JamesHutchison

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,11 @@
274274
{"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"}
275275
{"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"}
276276
{"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"}
277+
{"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"}
278+
{"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"}
279+
{"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"}
280+
{"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"}
281+
{"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"}
282+
{"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"}
283+
{"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"}
284+
{"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"}

pytest_hot_reloading/workarounds.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,28 @@ def pytest_django_tox_workaround() -> None:
4444
fixtures._set_suffix_to_test_databases = lambda suffix: None
4545

4646

47+
@register_workaround("vscode_pytest")
48+
def vscode_pytest_workaround() -> None:
49+
"""
50+
VS Code seems to keep track of collected tests and does a check to ensure
51+
they were not already collected before returning them.
52+
53+
Also, it uses a list when all it does is an existence check, so this swaps
54+
the list for a set with `append`.
55+
"""
56+
57+
import vscode_pytest # type: ignore
58+
59+
class SetWithAppendRemove(set):
60+
def append(self, val) -> None:
61+
self.add(val)
62+
63+
def remove(self, val) -> None:
64+
self.remove(val)
65+
66+
vscode_pytest.collected_tests_so_far = SetWithAppendRemove()
67+
68+
4769
def run_workarounds_pre() -> list[Generator]:
4870
in_progress_workarounds = []
4971
for module_name, workaround in workarounds:

0 commit comments

Comments
 (0)