~ubuntu-branches/ubuntu/utopic/dulwich/utopic

« back to all changes in this revision

Viewing changes to dulwich/tests/test_config.py

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2014-04-23 01:41:04 UTC
  • mfrom: (1.5.5)
  • Revision ID: package-import@ubuntu.com-20140423014104-nulhaisomztpfriy
Tags: 0.9.6-1
* New upstream release.
* Allow output to stderr in autopktest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
"""Tests for reading and writing configuration files."""
20
20
 
21
 
from cStringIO import StringIO
 
21
from io import BytesIO
22
22
from dulwich.config import (
23
23
    ConfigDict,
24
24
    ConfigFile,
37
37
class ConfigFileTests(TestCase):
38
38
 
39
39
    def from_file(self, text):
40
 
        return ConfigFile.from_file(StringIO(text))
 
40
        return ConfigFile.from_file(BytesIO(text))
41
41
 
42
42
    def test_empty(self):
43
43
        ConfigFile()
129
129
 
130
130
    def test_write_to_file_empty(self):
131
131
        c = ConfigFile()
132
 
        f = StringIO()
 
132
        f = BytesIO()
133
133
        c.write_to_file(f)
134
134
        self.assertEqual("", f.getvalue())
135
135
 
136
136
    def test_write_to_file_section(self):
137
137
        c = ConfigFile()
138
138
        c.set(("core", ), "foo", "bar")
139
 
        f = StringIO()
 
139
        f = BytesIO()
140
140
        c.write_to_file(f)
141
141
        self.assertEqual("[core]\n\tfoo = bar\n", f.getvalue())
142
142
 
143
143
    def test_write_to_file_subsection(self):
144
144
        c = ConfigFile()
145
145
        c.set(("branch", "blie"), "foo", "bar")
146
 
        f = StringIO()
 
146
        f = BytesIO()
147
147
        c.write_to_file(f)
148
148
        self.assertEqual("[branch \"blie\"]\n\tfoo = bar\n", f.getvalue())
149
149