view test/test_util.py @ 135:e5b4dea52297

Make more of RevisionPackager available to SourcePackager and BinaryPackager. This includes changing how SourcePackager and BinaryPackager are instantiated -- now the RevisionPackager instance is given as the first parameter to the __init__ method and most of the arguments formerly passed to __init__ are now automatiocally taken from that.
author Bernhard Herzog <bh@intevation.de>
date Tue, 27 May 2008 13:12:12 +0000
parents 7f6fb8103db0
children 017179427c7f
line wrap: on
line source
# Copyright (C) 2007, 2008 by Intevation GmbH
# Authors:
# Bernhard Herzog <bh@intevation.de>
#
# This program is free software under the GPL (>=v2)
# Read the file COPYING coming with the software for details.

"""Tests for the treepkg.util module"""

import unittest

from filesupport import FileTestMixin

from treepkg.util import replace_in_file


class TestReplaceInFile(unittest.TestCase, FileTestMixin):

    def runtest(self, orig_contents, expected_contents, pattern, replacement):
        filename = self.create_temp_file(self.id(), orig_contents)
        replace_in_file(filename, pattern, replacement)
        self.checkFileContents(filename, expected_contents)

    def test_version_replacement(self):
        template = ("project foo version 1.0-svn%(rev)d"
                    "Some filler"
                    "text that sometimes"
                    "looks similar to the pattern"
                    "1.0-"
                    "foo 1.2-svn2"
                    "echo foo version 1.0-svn%(rev)d"
                    ""
                    "and more filler")
        self.runtest(template % dict(rev=0), template % dict(rev=321),
                     r"1\.0-svn0", "1.0-svn321")
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)