def test_settings_exception(self): expected = ('Note that only Django core commands are listed as ' 'settings are not properly configured (error: foo).') utility = cli.OTreeManagementUtility([]) utility.settings_exception = "foo" main_help_text = utility.main_help_text().splitlines() self.assertEquals(main_help_text[-1], expected) utility = cli.OTreeManagementUtility([]) utility.settings_exception = None main_help_text = utility.main_help_text().splitlines() self.assertNotEquals(main_help_text[-1], expected)
def test_commands_only(self, *args): utility = cli.OTreeManagementUtility([]) main_help_text = utility.main_help_text().splitlines() for command in utility.main_help_text(commands_only=True).splitlines(): prefix = " {} - ".format(command) found = False for line in main_help_text: if line.startswith(prefix): found = True break if not found: self.fail("Command '{}' no found in help".format(command))
def test_help(self, *args): arguments = ["otree", "--help"] expected = StringIO() with mock.patch("sys.stdout", new=expected): cli.execute_from_command_line(arguments, "otree") utility = cli.OTreeManagementUtility(arguments) actual = StringIO() with mock.patch("sys.stdout", new=actual): utility.execute() self.assertEquals(actual.getvalue(), expected.getvalue())