title: How import python script that requires command line arguments before importing?
body: <p>Hi am trying to unit test a python script that requires command line arguments. This class is an AWS glue job but still pure python.</p>
  <p>Here is my unit test:</p>
  <pre><code>import sys
  import unittest
  
  import src.UnzipFile # Fails Here
  
  
  class TestUnzipFile(unittest.TestCase):
  
  
      def test_unzipping_file(self):
  
          &quot;&quot;&quot;
          Tests that it can unzip a tar.gz file
          &quot;&quot;&quot;
  
  
  if __name__ == &quot;__main__&quot;:
      try:
          unittest.main()
      except Exception:
          TestUnzipFile().tearDownClass()
  </code></pre>
  <p>Here is the beginning of the script that I am trying to import (short version):</p>
  <pre><code>args = getResolvedOptions(sys.argv,
  
                                [
                                    's3_bucket',
                                    'archive_path',
                                    'destination_path',
                                ])
  
  bucket_name = args['s3_bucket']
  
  tar_file_path = args['archive_path']
  
  
  if __name__ == &quot;__main__&quot;:
      main()
  </code></pre>
  <p>I get the following error after trying to import the script:</p>
  <pre><code>awsglue.utils.GlueArgumentError: the following arguments are required: --s3_bucket, --archive_path, --destination_path,
  </code></pre>
  <p>There is not a lot of documentation on unit testing of AWS glue jobs, and when a glue job is setup you cant use environment variables. Whatever parameters you want to use have to be arguments. So my question becomes how can I import a python script that requires arguments to be passed in?</p>