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


Python six.assertRegex方法代碼示例

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


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

示例1: test_default_oauth2_urls

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def test_default_oauth2_urls(self):
        flow_obj = DropboxOAuth2Flow('dummy_app_key', 'dummy_app_secret',
            'http://localhost/dummy', 'dummy_session', 'dbx-auth-csrf-token')

        six.assertRegex(
            self,
            flow_obj._get_authorize_url('http://localhost/redirect', 'state', 'legacy'),
            r'^https://{}/oauth2/authorize\?'.format(re.escape(session.WEB_HOST)),
        )

        self.assertEqual(
            flow_obj.build_url('/oauth2/authorize'),
            'https://{}/oauth2/authorize'.format(session.API_HOST),
        )

        self.assertEqual(
            flow_obj.build_url('/oauth2/authorize', host=session.WEB_HOST),
            'https://{}/oauth2/authorize'.format(session.WEB_HOST),
        ) 
開發者ID:dropbox,項目名稱:dropbox-sdk-python,代碼行數:21,代碼來源:test_dropbox.py

示例2: testSetup

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def testSetup(self, _mock_TurbiniaClient):
    """Tests that the processor is set up correctly."""
    test_state = state.DFTimewolfState(config.Config)
    turbinia_processor = turbinia.TurbiniaProcessor(test_state)
    turbinia_processor.SetUp(
        disk_name='disk-1',
        project='turbinia-project',
        turbinia_zone='europe-west1',
        sketch_id=123,
        run_all_jobs=False)
    self.assertEqual(turbinia_processor.disk_name, 'disk-1')
    self.assertEqual(turbinia_processor.project, 'turbinia-project')
    self.assertEqual(turbinia_processor.turbinia_zone, 'europe-west1')
    self.assertEqual(turbinia_processor.sketch_id, 123)
    self.assertEqual(turbinia_processor.run_all_jobs, False)
    self.assertEqual(test_state.errors, [])

    # TURBINIA_REGION is dynamically generated
    # pylint: disable=no-member
    self.assertEqual(turbinia_processor.turbinia_region,
                     turbinia.turbinia_config.TURBINIA_REGION)
    # pylint: disable=protected-access
    six.assertRegex(self, turbinia_processor._output_path,
                    '(/tmp/tmp|/var/folders).+') 
開發者ID:log2timeline,項目名稱:dftimewolf,代碼行數:26,代碼來源:turbinia.py

示例3: test_open_test_case

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def test_open_test_case(self):
        """
        Given: FuzzLoggerCsv with a virtual file handle.
        When: Calling open_test_case with some test_case_id.
        Then: open_test_case logs as expected.
        """
        # When
        self.logger.open_test_case(
            self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
        )

        # Then
        self.virtual_file.seek(0)
        six.assertRegex(
            self,
            self.virtual_file.readline(),
            LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
        ) 
開發者ID:jtpereyda,項目名稱:boofuzz,代碼行數:20,代碼來源:test_fuzz_logger_csv.py

示例4: test_log_info

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def test_log_info(self):
        """
        Given: FuzzLoggerCsv with a virtual file handle.
        When: Calling open_test_case with some test_case_id.
         and: Calling log_info with some description.
        Then: open_test_case logs as expected.
         and: log_info logs as expected.
        """
        # When
        self.logger.open_test_case(
            self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
        )
        self.logger.log_info(self.some_log_info_msg)

        # Then
        self.virtual_file.seek(0)
        six.assertRegex(
            self,
            self.virtual_file.readline(),
            LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
        )
        six.assertRegex(
            self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("info,,," + self.some_log_info_msg + "\r\n")
        ) 
開發者ID:jtpereyda,項目名稱:boofuzz,代碼行數:26,代碼來源:test_fuzz_logger_csv.py

示例5: test_log_fail

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def test_log_fail(self):
        """
        Given: FuzzLoggerCsv with a virtual file handle.
        When: Calling open_test_case with some test_case_id.
         and: Calling log_fail with some description.
        Then: open_test_case logs as expected.
         and: log_fail logs as expected.
        """
        # When
        self.logger.open_test_case(
            self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
        )
        self.logger.log_fail(self.some_log_fail_msg)

        # Then
        self.virtual_file.seek(0)
        six.assertRegex(
            self,
            self.virtual_file.readline(),
            LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
        )
        six.assertRegex(
            self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("fail,,," + self.some_log_fail_msg + "\r\n")
        ) 
開發者ID:jtpereyda,項目名稱:boofuzz,代碼行數:26,代碼來源:test_fuzz_logger_csv.py

示例6: test_log_pass

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def test_log_pass(self):
        """
        Given: FuzzLoggerCsv with a virtual file handle.
        When: Calling open_test_case with some test_case_id.
         and: Calling log_pass with some description.
        Then: open_test_case logs as expected.
         and: log_pass logs as expected.
        """
        # When
        self.logger.open_test_case(
            self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
        )
        self.logger.log_pass(self.some_log_pass_msg)

        # Then
        self.virtual_file.seek(0)
        six.assertRegex(
            self,
            self.virtual_file.readline(),
            LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
        )
        six.assertRegex(
            self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("pass,,," + self.some_log_pass_msg + "\r\n")
        ) 
開發者ID:jtpereyda,項目名稱:boofuzz,代碼行數:26,代碼來源:test_fuzz_logger_csv.py

示例7: test_open_test_step_empty

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def test_open_test_step_empty(self):
        """
        Given: FuzzLoggerCsv with a virtual file handle.
        When: Calling open_test_case with some test_case_id.
         and: Calling open_test_step with an empty string.
        Then: open_test_step logs with a zero-length description.
        """
        # When
        self.logger.open_test_case(
            self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
        )
        self.logger.open_test_step("")

        # Then
        self.virtual_file.seek(0)
        six.assertRegex(
            self,
            self.virtual_file.readline(),
            LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
        )
        six.assertRegex(self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("open step,,,\r\n")) 
開發者ID:jtpereyda,項目名稱:boofuzz,代碼行數:23,代碼來源:test_fuzz_logger_csv.py

示例8: test_log_check_empty

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def test_log_check_empty(self):
        """
        Given: FuzzLoggerCsv with a virtual file handle.
        When: Calling open_test_case with some test_case_id.
         and: Calling log_check with an empty string.
        Then: log_check logs with a zero-length description.
        """
        # When
        self.logger.open_test_case(
            self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
        )
        self.logger.log_check("")

        # Then
        self.virtual_file.seek(0)
        six.assertRegex(
            self,
            self.virtual_file.readline(),
            LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
        )
        six.assertRegex(self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("check,,,\r\n")) 
開發者ID:jtpereyda,項目名稱:boofuzz,代碼行數:23,代碼來源:test_fuzz_logger_csv.py

示例9: test_log_error_empty

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def test_log_error_empty(self):
        """
        Given: FuzzLoggerCsv with a virtual file handle.
        When: Calling open_test_case with some test_case_id.
         and: Calling log_error with an empty string.
        Then: log_error logs with a zero-length description.
        """
        # When
        self.logger.open_test_case(
            self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
        )
        self.logger.log_error("")

        # Then
        self.virtual_file.seek(0)
        six.assertRegex(
            self,
            self.virtual_file.readline(),
            LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
        )
        six.assertRegex(self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("error,,,\r\n")) 
開發者ID:jtpereyda,項目名稱:boofuzz,代碼行數:23,代碼來源:test_fuzz_logger_csv.py

示例10: test_log_fail_empty

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def test_log_fail_empty(self):
        """
        Given: FuzzLoggerCsv with a virtual file handle.
        When: Calling open_test_case with some test_case_id.
         and: Calling log_fail with no argument.
        Then: log_fail logs with a zero-length description.
        """
        # When
        self.logger.open_test_case(
            self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
        )
        self.logger.log_fail("")

        # Then
        self.virtual_file.seek(0)
        six.assertRegex(
            self,
            self.virtual_file.readline(),
            LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
        )
        six.assertRegex(self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("fail,,,\r\n")) 
開發者ID:jtpereyda,項目名稱:boofuzz,代碼行數:23,代碼來源:test_fuzz_logger_csv.py

示例11: test_log_pass_empty

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def test_log_pass_empty(self):
        """
        Given: FuzzLoggerCsv with a virtual file handle.
        When: Calling open_test_case with some test_case_id.
         and: Calling log_pass with no argument.
        Then: log_pass logs with a zero-length description.
        """
        # When
        self.logger.open_test_case(
            self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
        )
        self.logger.log_pass("")

        # Then
        self.virtual_file.seek(0)
        six.assertRegex(
            self,
            self.virtual_file.readline(),
            LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
        )
        six.assertRegex(self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("pass,,,\r\n")) 
開發者ID:jtpereyda,項目名稱:boofuzz,代碼行數:23,代碼來源:test_fuzz_logger_csv.py

示例12: assertQuickReplyLinks

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def assertQuickReplyLinks(self, output):
        """Assert reply links created by setup_quick_replies are present."""
        link = r'data-qr="%s">\s*%s\s*</a>'
        six.assertRegex(
            self, output.get_data(as_text=True), link % (self.r1, self.sr1)
        )
        six.assertRegex(
            self, output.get_data(as_text=True), link % (self.r2, self.sr2)
        ) 
開發者ID:Pagure,項目名稱:pagure,代碼行數:11,代碼來源:test_pagure_flask_ui_quick_reply.py

示例13: test_print_report

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def test_print_report(self):
        x = self.x
        self.f.apply((chainer.Variable(x),))
        self.f.apply((chainer.Variable(x),))
        io = six.StringIO()
        self.h.print_report(unit=self.unit, file=io)
        expect = r'''\AFunctionName +ElapsedTime +Occurrence
 +Exp +[0-9.\-e]+(.s|sec) +[0-9]+
\Z'''
        actual = io.getvalue()
        six.assertRegex(self, actual, expect) 
開發者ID:chainer,項目名稱:chainer,代碼行數:13,代碼來源:test_timer.py

示例14: test_print_report

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def test_print_report(self):
        io = six.StringIO()
        self.h.print_report(unit=self.unit, file=io)
        expect = r'''\AFunctionName  UsedBytes  AcquiredBytes  Occurrence
 +Exp +[0-9.\-e]+.?B +[0-9.\-e]+.?B +[0-9]+
 +ReLU +[0-9.\-e]+.?B +[0-9.\-e]+.?B +[0-9]+$
'''
        actual = io.getvalue()
        six.assertRegex(self, actual, expect) 
開發者ID:chainer,項目名稱:chainer,代碼行數:11,代碼來源:test_cupy_memory_profile.py

示例15: testInvalidBasicType

# 需要導入模塊: import six [as 別名]
# 或者: from six import assertRegex [as 別名]
def testInvalidBasicType(self):
    with self.assertRaises(SyntaxError) as assert_raises:
      self._parse_config("""
        scope/some_fn.arg1 = None
        scope/some_fn.arg2 = Garbage  # <-- Not a valid Python value.
      """)
    self.assertEqual(assert_raises.exception.lineno, 3)
    self.assertEqual(assert_raises.exception.offset, 29)
    self.assertEqual(
        assert_raises.exception.text.strip(),
        'scope/some_fn.arg2 = Garbage  # <-- Not a valid Python value.')
    six.assertRegex(self, str(assert_raises.exception),
                    r"malformed (string|node or string: <_ast.Name [^\n]+>)\n"
                    r"    Failed to parse token 'Garbage' \(line 3\)") 
開發者ID:google,項目名稱:gin-config,代碼行數:16,代碼來源:config_parser_test.py


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