def test_cmdline_copy_change_main(self): original = self.make_archive() target = self.tmpdir / 'target.pyz' args = [str(original), '-o', str(target), '-m', 'foo:bar'] with self.assertRaises(SystemExit) as cm: zipapp.main(args) self.assertTrue(cm.exception.code)
def test_cmdline_copy(self): # Test copying an archive. original = self.make_archive() target = self.tmpdir / 'target.pyz' args = [str(original), '-o', str(target)] zipapp.main(args) self.assertTrue(target.is_file())
def test_info_command(self, mock_stdout): target = self.make_archive() args = [str(target), '--info'] with self.assertRaises(SystemExit) as cm: zipapp.main(args) self.assertEqual(cm.exception.code, 0) self.assertEqual(mock_stdout.getvalue(), 'Interpreter: <none>\n')
def test_info_error(self): # Test the info command fails when the archive does not exist. target = self.tmpdir / 'dummy.pyz' args = [str(target), '--info'] with self.assertRaises(SystemExit) as cm: zipapp.main(args) # Program should exit with a non-zero returm code. self.assertTrue(cm.exception.code)
def test_cmdline_create(self): source = self.tmpdir / 'source' source.mkdir() (source / '__main__.py').touch() args = [str(source)] zipapp.main(args) target = source.with_suffix('.pyz') self.assertTrue(target.is_file())
def test_cmdline_copy_inplace(self): # Test copying an archive in place fails. original = self.make_archive() target = self.tmpdir / 'target.pyz' args = [str(original), '-o', str(original)] with self.assertRaises(SystemExit) as cm: zipapp.main(args) # Program should exit with a non-zero returm code. self.assertTrue(cm.exception.code)
def test_info_command(self, mock_stdout): # Test the output of the info command. target = self.make_archive() args = [str(target), '--info'] with self.assertRaises(SystemExit) as cm: zipapp.main(args) # Program should exit with a zero returm code. self.assertEqual(cm.exception.code, 0) self.assertEqual(mock_stdout.getvalue(), "Interpreter: <none>\n")
def test_cmdline_copy_change_main(self): # Test copying an archive doesn't allow changing __main__.py. original = self.make_archive() target = self.tmpdir / 'target.pyz' args = [str(original), '-o', str(target), '-m', 'foo:bar'] with self.assertRaises(SystemExit) as cm: zipapp.main(args) # Program should exit with a non-zero returm code. self.assertTrue(cm.exception.code)
def test_cmdline_create(self): # Test the basic command line API. source = self.tmpdir / 'source' source.mkdir() (source / '__main__.py').touch() args = [str(source)] zipapp.main(args) target = source.with_suffix('.pyz') self.assertTrue(target.is_file())
def test_info_error(self): target = self.tmpdir / 'dummy.pyz' args = [str(target), '--info'] with self.assertRaises(SystemExit) as cm: zipapp.main(args) self.assertTrue(cm.exception.code)
def run(self): import zipapp self.run_command('build_mo') log.info("Creating Zip App archive '%s'", self.output) zipapp.main(self.zipapp_args)
def update_event(self, inp=-1): self.set_output_val(0, zipapp.main(self.input(0)))