Esempio n. 1
0
    def test_quoted(self):
        cf = self.from_file(b"""[gui]
\tfontdiff = -family \\\"Ubuntu Mono\\\" -size 11 -overstrike 0
""")
        self.assertEqual(
            ConfigFile({
                (b'gui', ): {
                    b'fontdiff':
                    b'-family "Ubuntu Mono" -size 11 -overstrike 0',
                }
            }), cf)
Esempio n. 2
0
    def testSubmodules(self):
        cf = ConfigFile.from_file(
            BytesIO(b"""\
[submodule "core/lib"]
\tpath = core/lib
\turl = https://github.com/phhusson/QuasselC.git
"""))
        got = list(parse_submodules(cf))
        self.assertEqual(
            [(b'core/lib', b'https://github.com/phhusson/QuasselC.git',
              b'core/lib')], got)
Esempio n. 3
0
    def test_quoted_multiline(self):
        cf = self.from_file(b"""[alias]
who = \"!who() {\\
  git log --no-merges --pretty=format:'%an - %ae' $@ | uniq -c | sort -rn;\\
};\\
who\"
""")
        self.assertEqual(
            ConfigFile({
                (b'alias', ): {
                    b'who':
                    (b"!who() {git log --no-merges --pretty=format:'%an - "
                     b"%ae' $@ | uniq -c | sort -rn;};who")
                }
            }), cf)
Esempio n. 4
0
    def test_default_config(self):
        cf = self.from_file(b"""[core]
\trepositoryformatversion = 0
\tfilemode = true
\tbare = false
\tlogallrefupdates = true
""")
        self.assertEqual(
            ConfigFile({
                (b"core", ): {
                    b"repositoryformatversion": b"0",
                    b"filemode": b"true",
                    b"bare": b"false",
                    b"logallrefupdates": b"true"
                }
            }), cf)
Esempio n. 5
0
 def test_comment_after_variable(self):
     cf = self.from_file(b"[section]\nbar= foo # a comment\n")
     self.assertEqual(ConfigFile({(b"section", ): {b"bar": b"foo"}}), cf)
Esempio n. 6
0
 def test_comment_after_section(self):
     cf = self.from_file(b"[section] # foo\n")
     self.assertEqual(ConfigFile({(b"section", ): {}}), cf)
Esempio n. 7
0
 def test_comment_before_section(self):
     cf = self.from_file(b"# foo\n[section]\n")
     self.assertEqual(ConfigFile({(b"section", ): {}}), cf)
Esempio n. 8
0
 def test_empty_line_before_section(self):
     cf = self.from_file(b"\n[section]\n")
     self.assertEqual(ConfigFile({(b"section", ): {}}), cf)
Esempio n. 9
0
 def test_from_file_empty(self):
     cf = self.from_file(b"")
     self.assertEqual(ConfigFile(), cf)
Esempio n. 10
0
 def test_write_to_file_section(self):
     c = ConfigFile()
     c.set((b"core", ), b"foo", b"bar")
     f = BytesIO()
     c.write_to_file(f)
     self.assertEqual(b"[core]\n\tfoo = bar\n", f.getvalue())
Esempio n. 11
0
 def test_empty(self):
     ConfigFile()
Esempio n. 12
0
 def from_file(self, text):
     return ConfigFile.from_file(BytesIO(text))
Esempio n. 13
0
 def test_set_hash_gets_quoted(self):
     c = ConfigFile()
     c.set(b"xandikos", b"color", b"#665544")
     f = BytesIO()
     c.write_to_file(f)
     self.assertEqual(b"[xandikos]\n\tcolor = \"#665544\"\n", f.getvalue())
Esempio n. 14
0
 def test_write_to_file_subsection(self):
     c = ConfigFile()
     c.set((b"branch", b"blie"), b"foo", b"bar")
     f = BytesIO()
     c.write_to_file(f)
     self.assertEqual(b"[branch \"blie\"]\n\tfoo = bar\n", f.getvalue())
Esempio n. 15
0
 def test_comment_character_within_value_string(self):
     cf = self.from_file(b"[section]\nbar= \"foo#bar\"\n")
     self.assertEqual(ConfigFile({(b"section", ): {
                                      b"bar": b"foo#bar"
                                  }}), cf)
Esempio n. 16
0
 def test_eq(self):
     self.assertEqual(ConfigFile(), ConfigFile())
Esempio n. 17
0
 def test_comment_character_within_section_string(self):
     cf = self.from_file(b"[branch \"foo#bar\"] # a comment\nbar= foo\n")
     self.assertEqual(
         ConfigFile({(b"branch", b"foo#bar"): {
                         b"bar": b"foo"
                     }}), cf)
Esempio n. 18
0
 def test_write_to_file_empty(self):
     c = ConfigFile()
     f = BytesIO()
     c.write_to_file(f)
     self.assertEqual(b"", f.getvalue())