當前位置: 首頁>>代碼示例>>Python>>正文


Python BenchmarkOptions.parseOptions方法代碼示例

本文整理匯總了Python中benchmark.script.BenchmarkOptions.parseOptions方法的典型用法代碼示例。如果您正苦於以下問題:Python BenchmarkOptions.parseOptions方法的具體用法?Python BenchmarkOptions.parseOptions怎麽用?Python BenchmarkOptions.parseOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在benchmark.script.BenchmarkOptions的用法示例。


在下文中一共展示了BenchmarkOptions.parseOptions方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_empty_userdata

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
 def test_empty_userdata(self):
     """
     Empty option adds nothing to result.
     """
     options = BenchmarkOptions()
     options.parseOptions(['--userdata', ''])
     self.assertIs(parse_userdata(options), None)
開發者ID:332054781,項目名稱:flocker,代碼行數:9,代碼來源:test_script.py

示例2: test_json_userdata

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
 def test_json_userdata(self):
     """
     JSON string adds to result.
     """
     options = BenchmarkOptions()
     options.parseOptions(['--userdata', '{"branch": "master"}'])
     self.assertEqual(parse_userdata(options), {"branch": "master"})
開發者ID:332054781,項目名稱:flocker,代碼行數:9,代碼來源:test_script.py

示例3: test_no_userdata

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
 def test_no_userdata(self):
     """
     Missing option adds nothing to result.
     """
     options = BenchmarkOptions()
     options.parseOptions([])
     self.assertIs(parse_userdata(options), None)
開發者ID:332054781,項目名稱:flocker,代碼行數:9,代碼來源:test_script.py

示例4: test_json_file_userdata

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
 def test_json_file_userdata(self):
     """
     JSON file adds to result.
     """
     json_file = FilePath(self.mktemp())
     with json_file.open('w') as f:
         f.write('{"branch": "master"}\n')
     options = BenchmarkOptions()
     options.parseOptions(['--userdata', '@{}'.format(json_file.path)])
     self.assertEqual(parse_userdata(options), {"branch": "master"})
開發者ID:332054781,項目名稱:flocker,代碼行數:12,代碼來源:test_script.py

示例5: test_missing_environment

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
 def test_missing_environment(self):
     """
     If no cluster option and no environment, script fails
     """
     options = BenchmarkOptions()
     options.parseOptions([])
     with capture_stderr() as captured_stderr:
         with self.assertRaises(SystemExit) as e:
             get_cluster(options, {})
         self.assertIn('not set', e.exception.args[0])
         self.assertIn(options.getUsage(), captured_stderr())
開發者ID:sysuwbs,項目名稱:flocker,代碼行數:13,代碼來源:test_script.py

示例6: test_environment_hostname_mapping_invalid_json

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
 def test_environment_hostname_mapping_invalid_json(self):
     """
     Rejects configuration if hostname mapping is invalid.
     """
     options = BenchmarkOptions()
     options.parseOptions([])
     self.environ['FLOCKER_ACCEPTANCE_HOSTNAME_TO_PUBLIC_ADDRESS'] = '}'
     with capture_stderr() as captured_stderr:
         with self.assertRaises(SystemExit) as e:
             get_cluster(options, self.environ)
         self.assertIn('JSON', e.exception.args[0])
         self.assertIn(options.getUsage(), captured_stderr())
開發者ID:sysuwbs,項目名稱:flocker,代碼行數:14,代碼來源:test_script.py

示例7: test_environment_invalid_control_node

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
 def test_environment_invalid_control_node(self):
     """
     Rejects configuration if control node is invalid.
     """
     options = BenchmarkOptions()
     options.parseOptions([])
     self.environ['FLOCKER_ACCEPTANCE_CONTROL_NODE'] = 'notanipaddress'
     with capture_stderr() as captured_stderr:
         with self.assertRaises(SystemExit) as e:
             get_cluster(options, self.environ)
         self.assertIn('notanipaddress', e.exception.args[0])
         self.assertIn(options.getUsage(), captured_stderr())
開發者ID:sysuwbs,項目名稱:flocker,代碼行數:14,代碼來源:test_script.py

示例8: test_environment_setup_aws

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
    def test_environment_setup_aws(self):
        """
        Uses environment variables for cluster configuration if option missing.

        This test checks a typical AWS configuration.
        """
        options = BenchmarkOptions()
        options.parseOptions([])
        cluster = get_cluster(options, self.environ)
        self.assertEqual(
            cluster.control_node_address(),
            IPAddress(_ENV_CONTROL_SERVICE_ADDRESS)
        )
開發者ID:wangbinxiang,項目名稱:flocker,代碼行數:15,代碼來源:test_script.py

示例9: test_invalid_json

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
 def test_invalid_json(self):
     """
     Invalid JSON string handled.
     """
     options = BenchmarkOptions()
     options.parseOptions(['--userdata', '"branch": "master"'])
     with capture_stderr() as captured_stderr:
         exception = self.assertRaises(
             SystemExit, parse_userdata, options
         )
         self.assertIn(
             'Invalid user data', exception.args[0]
         )
         self.assertIn(options.getUsage(), captured_stderr())
開發者ID:332054781,項目名稱:flocker,代碼行數:16,代碼來源:test_script.py

示例10: test_environment_setup_rackspace

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
    def test_environment_setup_rackspace(self):
        """
        Uses environment variables for cluster configuration if option missing.

        This test checks a typical Rackspace configuration.
        """
        self.environ['FLOCKER_ACCEPTANCE_HOSTNAME_TO_PUBLIC_ADDRESS'] = '{}'
        self.environ['FLOCKER_ACCEPTANCE_VOLUME_BACKEND'] = 'openstack'
        options = BenchmarkOptions()
        options.parseOptions([])
        cluster = get_cluster(options, self.environ)
        self.assertEqual(
            cluster.control_node_address(),
            IPAddress(_ENV_CONTROL_SERVICE_ADDRESS)
        )
開發者ID:wangbinxiang,項目名稱:flocker,代碼行數:17,代碼來源:test_script.py

示例11: test_invalid_path

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
 def test_invalid_path(self):
     """
     Non-existent file handled.
     """
     no_file = FilePath(self.mktemp())
     options = BenchmarkOptions()
     options.parseOptions(['--userdata', '@{}'.format(no_file.path)])
     with capture_stderr() as captured_stderr:
         exception = self.assertRaises(
             SystemExit, parse_userdata, options
         )
         self.assertIn(
             'Invalid user data file', exception.args[0]
         )
         self.assertIn(options.getUsage(), captured_stderr())
開發者ID:332054781,項目名稱:flocker,代碼行數:17,代碼來源:test_script.py

示例12: test_environment_invalid_volume_size

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
 def test_environment_invalid_volume_size(self):
     """
     Rejects configuration if volume size is invalid.
     """
     options = BenchmarkOptions()
     options.parseOptions([])
     self.environ['FLOCKER_ACCEPTANCE_DEFAULT_VOLUME_SIZE'] = 'A'
     with capture_stderr() as captured_stderr:
         exception = self.assertRaises(
             SystemExit,
             get_cluster, options, self.environ,
         )
         self.assertIn(
             'FLOCKER_ACCEPTANCE_DEFAULT_VOLUME_SIZE', exception.args[0]
         )
         self.assertIn(options.getUsage(), captured_stderr())
開發者ID:wangbinxiang,項目名稱:flocker,代碼行數:18,代碼來源:test_script.py

示例13: test_environment_hostname_mapping_invalid_ipaddress

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
 def test_environment_hostname_mapping_invalid_ipaddress(self):
     """
     Rejects configuration if hostname mapping is invalid.
     """
     options = BenchmarkOptions()
     options.parseOptions([])
     self.environ['FLOCKER_ACCEPTANCE_HOSTNAME_TO_PUBLIC_ADDRESS'] = (
         '{"notanipaddress": "notanipaddress"}'
     )
     with capture_stderr() as captured_stderr:
         exception = self.assertRaises(
             SystemExit,
             get_cluster, options, self.environ,
         )
         self.assertIn('notanipaddress', exception.args[0])
         self.assertIn(options.getUsage(), captured_stderr())
開發者ID:wangbinxiang,項目名稱:flocker,代碼行數:18,代碼來源:test_script.py

示例14: test_missing_yaml_file

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
    def test_missing_yaml_file(self):
        """
        Script fails if cluster directory does not contain cluster.yml

        There is no fallback to environment if an error occurs reading
        YAML description.
        """
        tmpdir = tempfile.mkdtemp()
        self.addCleanup(shutil.rmtree, tmpdir)
        options = BenchmarkOptions()
        options.parseOptions(['--cluster', tmpdir])
        with capture_stderr() as captured_stderr:
            with self.assertRaises(SystemExit) as e:
                get_cluster(options, self.environ)
            self.assertIn('not found', e.exception.args[0])
            self.assertIn(options.getUsage(), captured_stderr())
開發者ID:sysuwbs,項目名稱:flocker,代碼行數:18,代碼來源:test_script.py

示例15: test_yaml_setup

# 需要導入模塊: from benchmark.script import BenchmarkOptions [as 別名]
# 或者: from benchmark.script.BenchmarkOptions import parseOptions [as 別名]
    def test_yaml_setup(self):
        """
        Uses YAML file for cluster configuration if option given.

        This is true even if the environment contains a valid configuration.
        """
        tmpdir = tempfile.mkdtemp()
        self.addCleanup(shutil.rmtree, tmpdir)
        with open(os.path.join(tmpdir, 'cluster.yml'), 'wt') as f:
            f.write(_CLUSTER_YAML_CONTENTS)
        options = BenchmarkOptions()
        options.parseOptions(['--cluster', tmpdir])
        cluster = get_cluster(options, self.environ)
        self.assertEqual(
            cluster.control_node_address(),
            IPAddress(_YAML_CONTROL_SERVICE_ADDRESS)
        )
開發者ID:wangbinxiang,項目名稱:flocker,代碼行數:19,代碼來源:test_script.py


注:本文中的benchmark.script.BenchmarkOptions.parseOptions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。