"""Exercise the repository scripts with real gettext tools in disposable trees.""" import os import json from pathlib import Path import shutil import subprocess import tempfile import unittest from shell_coverage import shell_command ROOT = Path(__file__).resolve().parents[2] TOOLS = ['xgettext', 'msgmerge', 'msgfmt', 'realpath'] @unittest.skipUnless(all(shutil.which(tool) for tool in TOOLS), 'GNU gettext and realpath required') class GettextScriptsTest(unittest.TestCase): def setUp(self): self.temp = tempfile.TemporaryDirectory(prefix='cacti gettext ') self.addCleanup(self.temp.cleanup) self.root = Path(self.temp.name) / 'checkout with spaces' self.locales = self.root / 'locales' (self.locales / 'po').mkdir(parents=True) (self.locales / 'LC_MESSAGES').mkdir() (self.root / 'include').mkdir() (self.root / 'include/cacti_version').write_text('1.3.0-dev\n') (self.root / 'input with spaces.php').write_text("