-
Notifications
You must be signed in to change notification settings - Fork 908
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
factor out function for getting top level directory of cloudinit #1136
Conversation
tests/unittests/test_subp.py
Outdated
python_prog = '\n'.join( | ||
[ | ||
'import json, sys', | ||
'sys.path.append("{}")'.format(get_top_level_dir()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting the pythonpath environment variable in subp didn't seem to work. That would have been cleaner, but this works too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you probably want to prepend, not append. The right 'cloudinit.subp' to import is the one in the top level dir, if there were others in the path for some reason then you'd get the wrong one.
that said, '' is (I think) usually the first token of sys.path, which is why this worked before. So I don't really think you have to change anything unless the intent is to execute these tests with some other working directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call @smoser. Thanks!
863908e
to
dceb2bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the overall approach...just some inline questions about the function implementation.
Also, I think test_schema.py, line 53 needs this too. It currently looks like
files = list(Path("../../cloudinit/config/").glob("cc_*.py"))
which doesn't work for me since I'm not running pytest from that directory. I have it replaced locally with
files = list(
(
Path(__file__).parent.parent.parent.parent / "cloudinit" / "config"
).glob("cc_*.py")
)
which is much less nice than using this would be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Additional Context