当前位置: 首页>>代码示例>>Python>>正文


Python RewriteRuleManager.read_rules方法代码示例

本文整理汇总了Python中carbon.rewrite.RewriteRuleManager.read_rules方法的典型用法代码示例。如果您正苦于以下问题:Python RewriteRuleManager.read_rules方法的具体用法?Python RewriteRuleManager.read_rules怎么用?Python RewriteRuleManager.read_rules使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在carbon.rewrite.RewriteRuleManager的用法示例。


在下文中一共展示了RewriteRuleManager.read_rules方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_read_clears_if_no_file

# 需要导入模块: from carbon.rewrite import RewriteRuleManager [as 别名]
# 或者: from carbon.rewrite.RewriteRuleManager import read_rules [as 别名]
  def test_read_clears_if_no_file(self):
    import carbon.rewrite
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'exists', Mock(return_value=False)):
      with patch.object(RewriteRuleManager, 'clear') as clear_mock:
        RewriteRuleManager.read_rules()
        clear_mock.assert_called_once_with()
开发者ID:Akulatraxas,项目名称:carbon,代码行数:10,代码来源:test_rewrite.py

示例2: test_read_records_mtime

# 需要导入模块: from carbon.rewrite import RewriteRuleManager [as 别名]
# 或者: from carbon.rewrite.RewriteRuleManager import read_rules [as 别名]
  def test_read_records_mtime(self):
    import carbon.rewrite
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'open', mock_open(), create=True):
      with patch.object(carbon.rewrite, 'exists', Mock(return_value=True)):
        with patch.object(carbon.rewrite, 'getmtime', Mock(return_value=1234)):
          RewriteRuleManager.read_rules()
    self.assertEqual(1234, RewriteRuleManager.rules_last_read)
开发者ID:Akulatraxas,项目名称:carbon,代码行数:11,代码来源:test_rewrite.py

示例3: test_read_opens_file_if_mtime_newer

# 需要导入模块: from carbon.rewrite import RewriteRuleManager [as 别名]
# 或者: from carbon.rewrite.RewriteRuleManager import read_rules [as 别名]
  def test_read_opens_file_if_mtime_newer(self):
    import carbon.rewrite
    RewriteRuleManager.rules_last_read = 1234
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'open', mock_open(), create=True) as open_mock:
      with patch.object(carbon.rewrite, 'exists', Mock(return_value=True)):
        with patch.object(carbon.rewrite, 'getmtime', Mock(return_value=5678)):
          RewriteRuleManager.read_rules()
          self.assertTrue(open_mock.called)
开发者ID:Akulatraxas,项目名称:carbon,代码行数:12,代码来源:test_rewrite.py

示例4: test_comments_ignored

# 需要导入模块: from carbon.rewrite import RewriteRuleManager [as 别名]
# 或者: from carbon.rewrite.RewriteRuleManager import read_rules [as 别名]
  def test_comments_ignored(self):
    import carbon.rewrite

    open_mock = Mock(return_value=iter(self.commented_config.splitlines()))
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'open', open_mock, create=True):
      with patch.object(carbon.rewrite, 'exists', Mock(return_value=True)):
        with patch.object(carbon.rewrite, 'getmtime', Mock(return_value=1234)):
          RewriteRuleManager.read_rules()
    self.assertEqual(1, len(RewriteRuleManager.rules('pre')))
开发者ID:Akulatraxas,项目名称:carbon,代码行数:13,代码来源:test_rewrite.py

示例5: test_section_parsed_into_ruleset

# 需要导入模块: from carbon.rewrite import RewriteRuleManager [as 别名]
# 或者: from carbon.rewrite.RewriteRuleManager import read_rules [as 别名]
  def test_section_parsed_into_ruleset(self):
    import carbon.rewrite

    open_mock = Mock(return_value=iter(self.sample_config.splitlines()))
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'open', open_mock, create=True):
      with patch.object(carbon.rewrite, 'exists', Mock(return_value=True)):
        with patch.object(carbon.rewrite, 'getmtime', Mock(return_value=1234)):
          RewriteRuleManager.read_rules()
    self.assertTrue('pre' in RewriteRuleManager.rulesets)
开发者ID:Akulatraxas,项目名称:carbon,代码行数:13,代码来源:test_rewrite.py

示例6: test_read_doesnt_open_file_if_mtime_unchanged

# 需要导入模块: from carbon.rewrite import RewriteRuleManager [as 别名]
# 或者: from carbon.rewrite.RewriteRuleManager import read_rules [as 别名]
  def test_read_doesnt_open_file_if_mtime_unchanged(self):
    import carbon.rewrite
    mtime = 1234
    RewriteRuleManager.rules_last_read = mtime
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'open', mock_open(), create=True) as open_mock:
      with patch.object(carbon.rewrite, 'exists', Mock(return_value=True)):
        with patch.object(carbon.rewrite, 'getmtime', Mock(return_value=1234)):
          RewriteRuleManager.read_rules()
          self.assertFalse(open_mock.called)
开发者ID:Akulatraxas,项目名称:carbon,代码行数:13,代码来源:test_rewrite.py

示例7: test_rules_unchanged_if_mtime_unchanged

# 需要导入模块: from carbon.rewrite import RewriteRuleManager [as 别名]
# 或者: from carbon.rewrite.RewriteRuleManager import read_rules [as 别名]
  def test_rules_unchanged_if_mtime_unchanged(self):
    import carbon.rewrite
    mtime = 1234
    rulesets = {'pre': [Mock(RewriteRule)]}
    RewriteRuleManager.rules_last_read = mtime
    RewriteRuleManager.rulesets.update(rulesets)
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'exists', Mock(return_value=True)):
      with patch.object(carbon.rewrite, 'getmtime', Mock(return_value=mtime)):
        RewriteRuleManager.read_rules()

    self.assertEqual(rulesets, RewriteRuleManager.rulesets)
开发者ID:Akulatraxas,项目名称:carbon,代码行数:15,代码来源:test_rewrite.py


注:本文中的carbon.rewrite.RewriteRuleManager.read_rules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。