Visitar URL original
Fail silently · Issue #2 · sloria/tinynetrc · GitHub
Skip to content

Fail silently #2

Closed
Closed

Description

@madisvain

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

Activity

  1. sloria commented on Jan 12, 2018

    @sloria
    Owner

    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.

  2. madisvain commented on Jan 13, 2018

    @madisvain
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions