~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-06-20 10:46:25 UTC
  • mfrom: (5987.1.1 799212-non-ascii-confs)
  • Revision ID: pqm@pqm.ubuntu.com-20110620104625-ih5t1e8w288pc4l2
(vila) Properly load utf8-encoded config files (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2328
2328
        self.assertRaises(AssertionError, store._load_from_string, 'bar=baz')
2329
2329
 
2330
2330
 
 
2331
class TestBug799212(TestStore):
 
2332
 
 
2333
   def test_load_utf8(self):
 
2334
        t = self.get_transport()
 
2335
        # From http://pad.lv/799212
 
2336
        unicode_user = u'Piotr O\u017carowski'
 
2337
        unicode_content = u'user=%s' % (unicode_user,)
 
2338
        utf8_content = unicode_content.encode('utf8')
 
2339
        # Store the raw content in the config file
 
2340
        t.put_bytes('foo.conf', utf8_content)
 
2341
        store = config.IniFileStore(t, 'foo.conf')
 
2342
        store.load()
 
2343
        stack = config.Stack([store.get_sections], store)
 
2344
        self.assertEquals(unicode_user, stack.get('user'))
 
2345
 
 
2346
 
2331
2347
class TestMutableStore(TestStore):
2332
2348
 
2333
2349
    scenarios = [(key, {'store_id': key, 'get_store': builder}) for key, builder