def test_two_extras_raises(self):
        old_content = textwrap.dedent(u"""
            [metadata]
            # something something
            name = fred

            [extras]
            a = b
            [extras]
            b = c

            [entry_points]
            console_scripts =
                foo = bar:quux
            """)
        with testtools.ExpectedException(parsley.ParseError):
            update.extras_compiled(old_content).ini()
    def test_none(self):
        old_content = textwrap.dedent(u"""
            [metadata]
            # something something
            name = fred

            [entry_points]
            console_scripts =
                foo = bar:quux
            """)
        ini = update.extras_compiled(old_content).ini()
        self.assertEqual(ini, (old_content, None, ''))
    def test_extras(self):
        # We get an AST for extras we can use to preserve comments.
        old_content = textwrap.dedent(u"""
            [metadata]
            # something something
            name = fred

            [extras]
            # comment1
            a =
             b
             c
            # comment2
            # comment3
            d =
             e
            # comment4

            [entry_points]
            console_scripts =
                foo = bar:quux
            """)
        prefix = textwrap.dedent(u"""
            [metadata]
            # something something
            name = fred

            """)
        suffix = textwrap.dedent(u"""\
            [entry_points]
            console_scripts =
                foo = bar:quux
            """)
        extras = [
            update.Comment('# comment1\n'),
            update.Extra('a', '\nb\nc\n'),
            update.Comment('# comment2\n'),
            update.Comment('# comment3\n'),
            update.Extra('d', '\ne\n'),
            update.Comment('# comment4\n')]
        ini = update.extras_compiled(old_content).ini()
        self.assertEqual(ini, (prefix, extras, suffix))
    def test_no_eol(self):
        old_content = textwrap.dedent(u"""
            [metadata]
            # something something
            name = fred

            [entry_points]
            console_scripts =
                foo = bar:quux""")
        expected1 = textwrap.dedent(u"""
            [metadata]
            # something something
            name = fred

            [entry_points]
            console_scripts =
            """)
        suffix = '    foo = bar:quux'
        ini = update.extras_compiled(old_content).ini()
        self.assertEqual(ini, (expected1, None, suffix))