def test_invalid_command_line_option_and_invalid_config(self):
    with temporary_dir(root_dir=os.path.abspath('.')) as tempdir:
      config_path = os.path.relpath(os.path.join(tempdir, 'config.ini'))
      with open(config_path, 'w+') as f:
        f.write(dedent("""
          [test.junit]
          bad_option: True

          [invalid_scope]
          abc: 123
        """))

      # Run with invalid config and invalid command line option.
      # Should error out with invalid command line option only.
      pants_run = self.run_pants(['--config-override={}'.format(config_path),
                                  '--test-junit-invalid=ALL',
                                  'goals'])
      self.assert_failure(pants_run)
      self.assertIn("Exception message: Unrecognized command line flags on scope 'test.junit': --invalid",
                    pants_run.stderr_data)

      # Run with invalid config only.
      # Should error out with `bad_option` and `invalid_scope` in config.
      pants_run = self.run_pants(['--config-override={}'.format(config_path),
                                  'goals'])
      self.assert_failure(pants_run)
      self.assertIn("ERROR] Invalid option 'bad_option' under [test.junit]", pants_run.stderr_data)
      self.assertIn("ERROR] Invalid scope [invalid_scope]", pants_run.stderr_data)
Make sure invalid command line error will be thrown and exits.
dataset/ETHPy150Open pantsbuild/pants/tests/python/pants_test/option/test_options_integration.py/TestOptionsIntegration.test_invalid_command_line_option_and_invalid_config