本文整理匯總了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()
示例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)
示例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)
示例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')))
示例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)
示例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)
示例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)