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

a couple of fixes for tests #117

Merged
merged 2 commits into from Aug 20, 2020
Merged

a couple of fixes for tests #117

merged 2 commits into from Aug 20, 2020

Conversation

chipaca
Copy link
Contributor

@chipaca chipaca commented Aug 13, 2020

fixes: #105

Copy link
Contributor

@facundobatista facundobatista left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

Copy link

@justinmclark justinmclark left a comment

Choose a reason for hiding this comment

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

Just one comment that is mostly for my own understanding. Other than that it looks good to me.


import pytest


@pytest.fixture(autouse=True, scope="session")
def tmpdir_under_tmpdir(tmpdir_factory):
tempfile.tempdir = str(tmpdir_factory.getbasetemp())

Choose a reason for hiding this comment

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

I was trying to understand how this works based on tmpdir_factory examples -- can all the tests using this fixture (which should be all of them due to autouse=True) access tempfile.tempdir?

Looking at docs, it seems as though when tempfile.tempdir is not None, it is only used as the dir default for other tempfile functions and it was unclear to me if it is useful outside of the context of the tempfile module: [1]

[1] https://docs.python.org/3/library/tempfile.html#tempfile.tempdir

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this change is exactly so charmcraft's calls to tempfile.mkstemp (in logsetup) use the test's tempdir instead of the default; this is the change that fixes #105.

@chipaca chipaca merged commit 4ede0f1 into canonical:master Aug 20, 2020
@chipaca chipaca deleted the two-tests-fixes branch August 20, 2020 10:11
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.

charmcraft-log files in /tmp
3 participants