File tree Expand file tree Collapse file tree 4 files changed +22
-5
lines changed
Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 11Changelog
22=========
33
4+ 1.2.0 (unreleased)
5+ ------------------
6+
7+ * Don't error if ``$HOME `` is not set `#2 <https://github.com/sloria/tinynetrc/issues/2 >`_.
8+
491.1.0 (2017-11-04)
510------------------
611
File renamed without changes.
Original file line number Diff line number Diff line change 77
88@pytest .fixture ()
99def netrc ():
10- return tinynetrc .Netrc (os .path .join (HERE , 'netrc_valid' ))
10+ return tinynetrc .Netrc (os .path .join (HERE , '.netrc' ))
11+
12+
13+ def test_file_not_found ():
14+ with pytest .raises (IOError ):
15+ tinynetrc .Netrc ('notfound' )
16+
17+
18+ def test_home_unset (monkeypatch ):
19+ # Make "~" == the current directory
20+ monkeypatch .setattr (os .path , 'expanduser' , lambda path : HERE )
21+ # Unset $HOME
22+ monkeypatch .delenv ('HOME' , raising = False )
23+ # No error
24+ result = tinynetrc .Netrc ()
25+ assert 'mail.google.com' in result .hosts
1126
1227
1328def test_hosts (netrc ):
Original file line number Diff line number Diff line change @@ -34,10 +34,7 @@ class Netrc(MutableMapping):
3434
3535 def __init__ (self , file = None ):
3636 if file is None :
37- try :
38- file = os .path .join (os .environ ['HOME' ], ".netrc" )
39- except KeyError :
40- raise OSError ("Could not find .netrc: $HOME is not set" )
37+ file = os .path .join (os .path .expanduser ('~' ), '.netrc' )
4138 self .file = file
4239 self ._netrc = netrc .netrc (file )
4340 self .machines = dictify_hosts (self ._netrc .hosts )
You can’t perform that action at this time.
0 commit comments