本文整理汇总了Python中static_precompiler.compilers.base.BaseCompiler.get_dependencies方法的典型用法代码示例。如果您正苦于以下问题:Python BaseCompiler.get_dependencies方法的具体用法?Python BaseCompiler.get_dependencies怎么用?Python BaseCompiler.get_dependencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static_precompiler.compilers.base.BaseCompiler
的用法示例。
在下文中一共展示了BaseCompiler.get_dependencies方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_dependencies
# 需要导入模块: from static_precompiler.compilers.base import BaseCompiler [as 别名]
# 或者: from static_precompiler.compilers.base.BaseCompiler import get_dependencies [as 别名]
def test_get_dependencies(self):
compiler = BaseCompiler()
self.assertFalse(Dependency.objects.exists())
self.assertEqual(
compiler.get_dependencies("spam.scss"),
[],
)
Dependency.objects.create(source="spam.scss", depends_on="ham.scss")
Dependency.objects.create(source="spam.scss", depends_on="eggs.scss")
self.assertEqual(
compiler.get_dependencies("spam.scss"),
["eggs.scss", "ham.scss"],
)
示例2: test_should_compile
# 需要导入模块: from static_precompiler.compilers.base import BaseCompiler [as 别名]
# 或者: from static_precompiler.compilers.base.BaseCompiler import get_dependencies [as 别名]
def test_should_compile(self):
compiler = BaseCompiler()
compiler.get_source_mtime = MagicMock()
compiler.get_output_mtime = MagicMock()
compiler.get_dependencies = MagicMock(return_value=["B", "C"])
mtimes = dict(
A=1,
B=3,
C=5,
)
compiler.get_source_mtime.side_effect = lambda x: mtimes[x]
compiler.get_output_mtime.return_value = None
self.assertTrue(compiler.should_compile("A"))
compiler.supports_dependencies = True
compiler.get_output_mtime.return_value = 6
self.assertFalse(compiler.should_compile("A"))
compiler.get_output_mtime.return_value = 5
self.assertTrue(compiler.should_compile("A"))
compiler.get_output_mtime.return_value = 4
self.assertTrue(compiler.should_compile("A"))
compiler.get_output_mtime.return_value = 2
self.assertTrue(compiler.should_compile("A"))
compiler.supports_dependencies = False
compiler.get_output_mtime.return_value = 2
self.assertFalse(compiler.should_compile("A"))
compiler.get_output_mtime.return_value = 1
self.assertTrue(compiler.should_compile("A"))
compiler.get_output_mtime.return_value = 0
self.assertTrue(compiler.should_compile("A"))
compiler.get_source_mtime.reset_mock()
with patch("static_precompiler.compilers.base.DISABLE_AUTO_COMPILE"):
self.assertFalse(compiler.should_compile("A"))
self.assertFalse(compiler.get_source_mtime.called)
示例3: test_should_compile
# 需要导入模块: from static_precompiler.compilers.base import BaseCompiler [as 别名]
# 或者: from static_precompiler.compilers.base.BaseCompiler import get_dependencies [as 别名]
def test_should_compile(self):
compiler = BaseCompiler()
compiler.get_source_mtime = MagicMock()
compiler.get_output_mtime = MagicMock()
compiler.get_dependencies = MagicMock(return_value=["B", "C"])
mtimes = dict(
A=1,
B=3,
C=5,
)
compiler.get_source_mtime.side_effect = lambda x: mtimes[x]
compiler.get_output_mtime.return_value = None
self.assertTrue(compiler.should_compile("A"))
compiler.supports_dependencies = True
compiler.get_output_mtime.return_value = 6
self.assertFalse(compiler.should_compile("A"))
compiler.get_output_mtime.return_value = 5
self.assertTrue(compiler.should_compile("A"))
compiler.get_output_mtime.return_value = 4
self.assertTrue(compiler.should_compile("A"))
compiler.get_output_mtime.return_value = 2
self.assertTrue(compiler.should_compile("A"))
compiler.supports_dependencies = False
compiler.get_output_mtime.return_value = 2
self.assertFalse(compiler.should_compile("A"))
compiler.get_output_mtime.return_value = 1
self.assertTrue(compiler.should_compile("A"))
compiler.get_output_mtime.return_value = 0
self.assertTrue(compiler.should_compile("A"))