Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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())
Ejemplo n.º 3
0
 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())
Ejemplo n.º 4
0
 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')
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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())
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 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")
Ejemplo n.º 10
0
 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)
Ejemplo n.º 11
0
 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)
Ejemplo n.º 12
0
 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")
Ejemplo n.º 13
0
 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)
Ejemplo n.º 14
0
 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())
Ejemplo n.º 15
0
 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)
Ejemplo n.º 16
0
 def run(self):
     import zipapp
     self.run_command('build_mo')
     log.info("Creating Zip App archive '%s'", self.output)
     zipapp.main(self.zipapp_args)
Ejemplo n.º 17
0
 def update_event(self, inp=-1):
     self.set_output_val(0, zipapp.main(self.input(0)))