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

extra_template_vars plugin hook #542

Merged
merged 3 commits into from
Jul 6, 2019
Merged

extra_template_vars plugin hook #542

merged 3 commits into from
Jul 6, 2019

Conversation

simonw
Copy link
Owner

@simonw simonw commented Jul 5, 2019

Refs #541

@simonw
Copy link
Owner Author

simonw commented Jul 5, 2019

I'm getting this weird failure again:

self = <click.testing.CliRunner object at 0x7f4295b7bd30>
    @contextlib.contextmanager
    def isolated_filesystem(self):
        """A context manager that creates a temporary folder and changes
        the current working directory to it for isolated filesystem tests.
        """
>       cwd = os.getcwd()
E       FileNotFoundError: [Errno 2] No such file or directory

I saw this the other day too, but managed to avoid it by skipping any code that messed around with temporary files.

Baffled as to why this is showing up now, as none of the changes I'm making here have any relevance to the way temporary files are created or the current working directory is set.

I understand the root cause here to be that the working directory for the tests was deleted while the tests were still running, which would seem to indicate that something to do with a tmpdir fixture is at fault.

@simonw
Copy link
Owner Author

simonw commented Jul 5, 2019

I bet that error is something to do with this:

for client in make_app_client(
template_dir=str(pathlib.Path(__file__).parent / "test_templates")
):

@simonw
Copy link
Owner Author

simonw commented Jul 5, 2019

I've confirmed that it's the template_dir= line quoted above. It isn't the fault of pathlib - if you hard-code in the path string like this I still get the same failures:

    template_dir = "/Users/simonw/Dropbox/Development/datasette/tests/test_templates"
    for client in make_app_client(
        template_dir=template_dir
    ):

So for some reason setting template_dir to a concrete directory breaks those other tests.

@simonw
Copy link
Owner Author

simonw commented Jul 5, 2019

Here's what isolated_filesystem() does:

A context manager that creates a temporary folder and changes the current working directory to it for isolated filesystem tests.

pallets/click#395 is a four year old issue suggesting allowing it to have a parent tmp directory passed to it, but since that issue was never closed I don't think it's going to help me.

@simonw
Copy link
Owner Author

simonw commented Jul 5, 2019

This looks relevant: pytest-dev/pytest#1235 - "pytest explodes if getcwd fails"

@simonw simonw merged commit fcfcae2 into master Jul 6, 2019
simonw added a commit that referenced this pull request Jul 7, 2019
* extra_template_vars plugin hook

Closes #541

* Workaround for cwd bug

Based on pytest-dev/pytest#1235 (comment)
simonw added a commit that referenced this pull request Nov 11, 2019
* extra_template_vars plugin hook

Closes #541

* Workaround for cwd bug

Based on pytest-dev/pytest#1235 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant