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

Fail silently #2

Closed
madisvain opened this issue Jan 12, 2018 · 2 comments
Closed

Fail silently #2

madisvain opened this issue Jan 12, 2018 · 2 comments

Comments

@madisvain
Copy link

madisvain commented Jan 12, 2018

Currently if I use Travis for testing then using this library makes tests fail as it does not gracfully fail if it does not find the .netrc file.

==================================== ERRORS ====================================
___________________ ERROR collecting tests/test_siteship.py ____________________
.tox/py36/lib/python3.6/site-packages/tinynetrc.py:38: in __init__
    file = os.path.join(os.environ['HOME'], ".netrc")
.tox/py36/lib/python3.6/os.py:669: in __getitem__
    raise KeyError(key) from None
E   KeyError: 'HOME'
During handling of the above exception, another exception occurred:
tests/test_siteship.py:11: in <module>
    from siteship import cli
siteship/cli.py:14: in <module>
    netrc = Netrc()
.tox/py36/lib/python3.6/site-packages/tinynetrc.py:40: in __init__
    raise OSError("Could not find .netrc: $HOME is not set")
E   OSError: Could not find .netrc: $HOME is not set

https://travis-ci.org/siteship/siteship-cli

@sloria
Copy link
Owner

sloria commented Jan 12, 2018

Thanks for reporting @madisvain .

The current behavior matches the behavior in the netrc module in the stdlib as of Python 3.6.

It looks like the behavior was changed for 3.7 by python/cpython#4537 . Now, an error is not raised if $HOME isn't set. I'll go ahead and update tinynetrc to match the new behavior.

Keep in mind that an error will still be raised if the netrc file is not found, so you'll need to handle FileNotFoundError accordingly.

@sloria sloria closed this as completed in d923e8d Jan 12, 2018
@madisvain
Copy link
Author

@sloria that was quick - I was going to look into this over the weekend ... already done.

Thank you!

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

No branches or pull requests

2 participants