def test_no_unicode_in_help_strings(self, mock_stdout): helps = ['topics'] for key in _TOPICS.keys(): helps.append(str(key)) # Get a list of plugins import snapcraft.plugins import os from pathlib import Path for plugin in Path(snapcraft.plugins.__path__[0]).glob('*.py'): if (os.path.isfile(str(plugin)) and not os.path.basename(str(plugin)).startswith('_')): helps.append(os.path.basename(str(plugin)[:-3])) for key in helps: mock_stdout.truncate(0) mock_stdout.seek(0) with self.subTest(key=key): main(['help', key]) try: mock_stdout.getvalue().encode('ascii') except UnicodeEncodeError: self.fail('Non-ASCII characters in help text for ' '{!r}'.format(key))
def test_no_unicode_in_help_strings(self): helps = ['topics'] for key in _TOPICS.keys(): helps.append(str(key)) # Get a list of plugins import snapcraft.plugins import os from pathlib import Path for plugin in Path(snapcraft.plugins.__path__[0]).glob('*.py'): if (os.path.isfile(str(plugin)) and not os.path.basename(str(plugin)).startswith('_')): helps.append(os.path.basename(str(plugin)[:-3])) for key in helps: fake_terminal = fixture_setup.FakeTerminal() self.useFixture(fake_terminal) main(['help', key]) # An UnicodeEncodeError will be raised if the help text has # non-ASCII characters. fake_terminal.getvalue().encode('ascii')