~cjwatson/launchpad-buildd/twisted-17.1.0-compat

« back to all changes in this revision

Viewing changes to lpbuildd/pottery/tests/test_intltool.py

[r=wgrant] Fall back to the package name from AC_INIT when expanding $(PACKAGE) in
translation configuration files if no other definition can be found.

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
            "packagename-ac",
200
200
            get_translation_domain(backend, os.path.join(package_dir, "po")))
201
201
 
202
 
    def prepare_ac_init(self, parameters):
 
202
    def prepare_ac_init(self, parameters, extra_files=None):
203
203
        # Prepare test for various permutations of AC_INIT parameters
204
204
        configure_ac_content = dedent("""
205
205
            AC_INIT(%s)
206
206
            GETTEXT_PACKAGE=AC_PACKAGE_NAME
207
207
            """) % parameters
208
 
        return self.prepare_package(
209
 
            "intltool_domain_base",
210
 
            {
211
 
                "configure.ac": configure_ac_content,
212
 
            })
 
208
        files = {"configure.ac": configure_ac_content}
 
209
        if extra_files is not None:
 
210
            files.update(extra_files)
 
211
        return self.prepare_package("intltool_domain_base", files)
213
212
 
214
213
    def test_get_translation_domain_configure_ac_init(self):
215
214
        # Find a translation domain in configure.ac in AC_INIT.
266
265
            "package-tarname",
267
266
            get_translation_domain(backend, os.path.join(package_dir, "po")))
268
267
 
 
268
    def test_get_translation_domain_substitute_package_from_ac_init(self):
 
269
        # PACKAGE is substituted from AC_INIT parameters as a fallback.
 
270
        backend = UncontainedBackend("1")
 
271
        package_dir = self.prepare_ac_init(
 
272
            "[packagename-ac-init], 1.0, http://bug.org",
 
273
            {"po/Makevars": "DOMAIN = $(PACKAGE)\n"})
 
274
        self.assertEqual(
 
275
            "packagename-ac-init",
 
276
            get_translation_domain(backend, os.path.join(package_dir, "po")))
 
277
 
269
278
    def test_get_translation_domain_configure_in(self):
270
279
        # Find a translation domain in configure.in.
271
280
        backend = UncontainedBackend("1")