github.com/sercand/please@v13.4.0+incompatible/test/python_rules/strip_source_test.py (about)

     1  """Tests on source stripping."""
     2  
     3  import os
     4  import subprocess
     5  import unittest
     6  import zipfile
     7  
     8  
     9  class StripSourceTest(unittest.TestCase):
    10  
    11      def setUp(self):
    12          self.filename = [x for x in os.environ['DATA'].split(' ') if x.endswith('.pex')][0]
    13  
    14      def test_can_run_binary(self):
    15          """Test that the dependent binary can be run successfully."""
    16          subprocess.check_call([self.filename])
    17  
    18      def test_does_not_have_py_file(self):
    19          """Test that the binary doesn't have the source in it."""
    20          with zipfile.ZipFile(self.filename) as zf:
    21              zf.getinfo('test/python_rules/strip_source.pyc')
    22              with self.assertRaises(KeyError):
    23                  zf.getinfo('test/python_rules/strip_source.py')