def test_show_formats(self): __, stdout = captured_stdout(show_formats) # the output should be a header line + one line per format num_formats = len(get_archive_formats()) output = [line for line in stdout.split("\n") if line.strip().startswith("--formats=")] self.assertEquals(len(output), num_formats)
def _test_debug_mode(self): # this covers the code called when DEBUG is set old_logs_len = len(self.logs) install_module.DEBUG = True try: __, stdout = captured_stdout(self.test_record) finally: install_module.DEBUG = False self.assertTrue(len(self.logs) > old_logs_len)
def test_show_help(self): # smoke test, just makes sure some help is displayed dist = Distribution() sys.argv = [] dist.help = 1 dist.script_name = "setup.py" __, stdout = captured_stdout(dist.parse_command_line) output = [line for line in stdout.split("\n") if line.strip() != ""] self.assertTrue(len(output) > 0)
def test_debug_mode(self): f = open(TESTFN, "w") try: f.write("[global]") f.write("command_packages = foo.bar, splat") finally: f.close() files = [TESTFN] sys.argv.append("build") __, stdout = captured_stdout(self.create_distribution, files) self.assertEquals(stdout, "") distutils2.dist.DEBUG = True try: __, stdout = captured_stdout(self.create_distribution, files) self.assertEquals(stdout, "") finally: distutils2.dist.DEBUG = False