{"html_url": "https://github.com/simonw/datasette/issues/1406#issuecomment-890390342", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1406", "id": 890390342, "node_id": "IC_kwDOBm6k_c41EkdG", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-07-31T18:56:35Z", "updated_at": "2021-07-31T18:56:35Z", "author_association": "OWNER", "body": "But... I've lost enough time to this already, and removing `runner.isolated_filesystem()` has the tests passing again. So I'm not going to work on this any more.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 956303470, "label": "Tests failing with FileNotFoundError in runner.isolated_filesystem"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1406#issuecomment-890390198", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1406", "id": 890390198, "node_id": "IC_kwDOBm6k_c41Eka2", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-07-31T18:55:33Z", "updated_at": "2021-07-31T18:55:33Z", "author_association": "OWNER", "body": "To clarify: the core problem here is that an error is thrown any time you call `os.getcwd()` but the directory you are currently in has been deleted.\r\n\r\n`runner.isolated_filesystem()` assumes that the current directory in has not been deleted. But the various temporary directory utilities in `pytest` work by creating directories and then deleting them.\r\n\r\nMaybe there's a larger problem here that I play a bit fast and loose with `os.chdir()` in both the test suite and in various lines of code in Datasette itself (in particular in the publish commands)?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 956303470, "label": "Tests failing with FileNotFoundError in runner.isolated_filesystem"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1406#issuecomment-890259755", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1406", "id": 890259755, "node_id": "IC_kwDOBm6k_c41EEkr", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-07-31T00:04:54Z", "updated_at": "2021-07-31T00:04:54Z", "author_association": "OWNER", "body": "STILL failing. I'm going to try removing all instances of `isolated_filesystem()` in favour of a different pattern using pytest temporary files, then see if I can get that to work without the serial hack. ", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 956303470, "label": "Tests failing with FileNotFoundError in runner.isolated_filesystem"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1406#issuecomment-889555977", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1406", "id": 889555977, "node_id": "IC_kwDOBm6k_c41BYwJ", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-07-30T01:06:57Z", "updated_at": "2021-07-30T01:06:57Z", "author_association": "OWNER", "body": "Looking at the source code in Click for `isolated_filesystem()`: https://github.com/pallets/click/blob/9da166957f5848b641231d485467f6140bca2bc0/src/click/testing.py#L450-L468\r\n\r\n```python\r\n @contextlib.contextmanager\r\n def isolated_filesystem(\r\n self, temp_dir: t.Optional[t.Union[str, os.PathLike]] = None\r\n ) -> t.Iterator[str]:\r\n \"\"\"A context manager that creates a temporary directory and\r\n changes the current working directory to it. This isolates tests\r\n that affect the contents of the CWD to prevent them from\r\n interfering with each other.\r\n :param temp_dir: Create the temporary directory under this\r\n directory. If given, the created directory is not removed\r\n when exiting.\r\n .. versionchanged:: 8.0\r\n Added the ``temp_dir`` parameter.\r\n \"\"\"\r\n cwd = os.getcwd()\r\n t = tempfile.mkdtemp(dir=temp_dir)\r\n os.chdir(t)\r\n```\r\nHow about if I pass in that optional `temp_dir` as a temp directory created using the `pytest-xdist` aware pytest mechanisms: https://docs.pytest.org/en/6.2.x/tmpdir.html", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 956303470, "label": "Tests failing with FileNotFoundError in runner.isolated_filesystem"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1406#issuecomment-889553052", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1406", "id": 889553052, "node_id": "IC_kwDOBm6k_c41BYCc", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-07-30T00:58:43Z", "updated_at": "2021-07-30T00:58:43Z", "author_association": "OWNER", "body": "Tests are still failing in the job that calculates coverage.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 956303470, "label": "Tests failing with FileNotFoundError in runner.isolated_filesystem"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1406#issuecomment-889550391", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1406", "id": 889550391, "node_id": "IC_kwDOBm6k_c41BXY3", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-07-30T00:49:31Z", "updated_at": "2021-07-30T00:49:31Z", "author_association": "OWNER", "body": "That fixed it. My hunch is that Click's `runner.isolated_filesystem()` mechanism doesn't play well with `pytest-xdist`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 956303470, "label": "Tests failing with FileNotFoundError in runner.isolated_filesystem"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1406#issuecomment-889548536", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1406", "id": 889548536, "node_id": "IC_kwDOBm6k_c41BW74", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-07-30T00:43:47Z", "updated_at": "2021-07-30T00:43:47Z", "author_association": "OWNER", "body": "Still couldn't replicate on my laptop. On a hunch, I'm going to add `@pytest.mark.serial` to every test that uses `runner.isolated_filesystem()`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 956303470, "label": "Tests failing with FileNotFoundError in runner.isolated_filesystem"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1406#issuecomment-889547142", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1406", "id": 889547142, "node_id": "IC_kwDOBm6k_c41BWmG", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-07-30T00:39:49Z", "updated_at": "2021-07-30T00:39:49Z", "author_association": "OWNER", "body": "It happens in CI but not on my laptop. I think I need to run the tests on my laptop like this: https://github.com/simonw/datasette/blob/121e10c29c5b412fddf0326939f1fe46c3ad9d4a/.github/workflows/test.yml#L27-L30", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 956303470, "label": "Tests failing with FileNotFoundError in runner.isolated_filesystem"}, "performed_via_github_app": null}