~james-page/bzr/unittest2-assertWarns

« back to all changes in this revision

Viewing changes to bzrlib/plugins/netrc_credential_store/tests/test_netrc.py

  • Committer: Patch Queue Manager
  • Date: 2013-10-04 09:37:29 UTC
  • mfrom: (6587.1.2 1233413-netrc)
  • Revision ID: pqm@pqm.ubuntu.com-20131004093729-to7tbu9w6ws03wge
(vila) Make .netrc 0600 in tests so python-2.7.5-8's netrc is happy.
 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
machine host login joe password secret
44
44
default login anonymous password joe@home
45
45
"""
46
 
        f = open(osutils.pathjoin(self.test_home_dir, '.netrc'), 'wb')
47
 
        try:
 
46
        netrc_path = osutils.pathjoin(self.test_home_dir, '.netrc')
 
47
        with open(netrc_path, 'wb') as f:
48
48
            f.write(netrc_content)
49
 
        finally:
50
 
            f.close()
 
49
        # python's netrc will complain about access permissions starting with
 
50
        # 2.7.5-8 so we restrict the access unconditionally
 
51
        osutils.chmod_if_possible(netrc_path, 0600)
51
52
 
52
53
    def _get_netrc_cs(self):
53
54
        return  config.credential_store_registry.get_credential_store('netrc')