我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用distutils.dist.command_packages()。
def test_debug_mode(self): with open(TESTFN, "w") as f: f.write("[global]\n") f.write("command_packages = foo.bar, splat") self.addCleanup(unlink, TESTFN) files = [TESTFN] sys.argv.append("build") with captured_stdout() as stdout: self.create_distribution(files) stdout.seek(0) self.assertEqual(stdout.read(), '') distutils.dist.DEBUG = True try: with captured_stdout() as stdout: self.create_distribution(files) stdout.seek(0) self.assertEqual(stdout.read(), '') finally: distutils.dist.DEBUG = False
def test_command_packages_configfile(self): sys.argv.append("build") self.addCleanup(os.unlink, TESTFN) f = open(TESTFN, "w") try: print >> f, "[global]" print >> f, "command_packages = foo.bar, splat" finally: f.close() d = self.create_distribution([TESTFN]) self.assertEqual(d.get_command_packages(), ["distutils.command", "foo.bar", "splat"]) # ensure command line overrides config: sys.argv[1:] = ["--command-packages", "spork", "build"] d = self.create_distribution([TESTFN]) self.assertEqual(d.get_command_packages(), ["distutils.command", "spork"]) # Setting --command-packages to '' should cause the default to # be used even if a config file specified something else: sys.argv[1:] = ["--command-packages", "", "build"] d = self.create_distribution([TESTFN]) self.assertEqual(d.get_command_packages(), ["distutils.command"])
def test_debug_mode(self): with open(TESTFN, "w") as f: f.write("[global]\n") f.write("command_packages = foo.bar, splat") files = [TESTFN] sys.argv.append("build") with captured_stdout() as stdout: self.create_distribution(files) stdout.seek(0) self.assertEqual(stdout.read(), '') distutils.dist.DEBUG = True try: with captured_stdout() as stdout: self.create_distribution(files) stdout.seek(0) self.assertEqual(stdout.read(), '') finally: distutils.dist.DEBUG = False
def test_get_command_packages(self): dist = Distribution() self.assertEqual(dist.command_packages, None) cmds = dist.get_command_packages() self.assertEqual(cmds, ['distutils.command']) self.assertEqual(dist.command_packages, ['distutils.command']) dist.command_packages = 'one,two' cmds = dist.get_command_packages() self.assertEqual(cmds, ['distutils.command', 'one', 'two'])