~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2013-10-01 13:13:46 UTC
  • mto: This revision was merged to the branch mainline in revision 6588.
  • Revision ID: v.ladeuil+lp@free.fr-20131001131346-pkcqu4do6wt0amn1
Make .netrc 0600 in tests to fix python-2.7.5-8's netrc happy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
from cStringIO import StringIO
 
18
import os
18
19
 
19
20
from bzrlib import (
20
21
    config,
43
44
machine host login joe password secret
44
45
default login anonymous password joe@home
45
46
"""
46
 
        f = open(osutils.pathjoin(self.test_home_dir, '.netrc'), 'wb')
47
 
        try:
 
47
        netrc_path = osutils.pathjoin(self.test_home_dir, '.netrc')
 
48
        with open(netrc_path, 'wb') as f:
48
49
            f.write(netrc_content)
49
 
        finally:
50
 
            f.close()
 
50
        # python's netrc will complain about access permissions starting with
 
51
        # 2.7.5-8 so we restrict the access unconditionally
 
52
        os.chmod(netrc_path, 0600)
51
53
 
52
54
    def _get_netrc_cs(self):
53
55
        return  config.credential_store_registry.get_credential_store('netrc')