本文整理汇总了Python中static_precompiler.compilers.base.BaseCompiler.get_output_path方法的典型用法代码示例。如果您正苦于以下问题:Python BaseCompiler.get_output_path方法的具体用法?Python BaseCompiler.get_output_path怎么用?Python BaseCompiler.get_output_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static_precompiler.compilers.base.BaseCompiler
的用法示例。
在下文中一共展示了BaseCompiler.get_output_path方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_full_output_path
# 需要导入模块: from static_precompiler.compilers.base import BaseCompiler [as 别名]
# 或者: from static_precompiler.compilers.base.BaseCompiler import get_output_path [as 别名]
def test_get_full_output_path(self):
compiler = BaseCompiler()
compiler.get_output_path = MagicMock(
return_value=OUTPUT_DIR + "/dummy.js")
self.assertEqual(
compiler.get_full_output_path("dummy.coffee"),
os.path.join(ROOT, OUTPUT_DIR, "dummy.js"))
示例2: test_get_output_path
# 需要导入模块: from static_precompiler.compilers.base import BaseCompiler [as 别名]
# 或者: from static_precompiler.compilers.base.BaseCompiler import get_output_path [as 别名]
def test_get_output_path(self):
compiler = BaseCompiler()
compiler.get_output_filename = MagicMock(
side_effect=
lambda source_path: source_path.replace(".coffee", ".js"))
self.assertEqual(
compiler.get_output_path("scripts/test.coffee"),
OUTPUT_DIR + "/scripts/test.js")
示例3: test_compile
# 需要导入模块: from static_precompiler.compilers.base import BaseCompiler [as 别名]
# 或者: from static_precompiler.compilers.base.BaseCompiler import get_output_path [as 别名]
def test_compile(self):
compiler = BaseCompiler()
compiler.is_supported = MagicMock()
compiler.should_compile = MagicMock()
compiler.compile_file = MagicMock(return_value="compiled")
compiler.write_output = MagicMock()
compiler.get_output_path = MagicMock(return_value="dummy.js")
compiler.postprocess = MagicMock(
side_effect=lambda compiled, source_path: compiled
)
compiler.update_dependencies = MagicMock()
compiler.find_dependencies = MagicMock(return_value=["A", "B"])
compiler.is_supported.return_value = False
self.assertRaises(ValueError, lambda: compiler.compile("dummy.coffee"))
self.assertEqual(compiler.compile_file.call_count, 0)
self.assertEqual(compiler.postprocess.call_count, 0)
self.assertEqual(compiler.write_output.call_count, 0)
compiler.is_supported.return_value = True
compiler.should_compile.return_value = False
self.assertEqual(compiler.compile("dummy.coffee"), "dummy.js")
self.assertEqual(compiler.compile_file.call_count, 0)
self.assertEqual(compiler.postprocess.call_count, 0)
self.assertEqual(compiler.write_output.call_count, 0)
compiler.should_compile.return_value = True
self.assertEqual(compiler.compile("dummy.coffee"), "dummy.js")
self.assertEqual(compiler.compile_file.call_count, 1)
compiler.compile_file.assert_called_with("dummy.coffee")
self.assertEqual(compiler.postprocess.call_count, 1)
compiler.postprocess.assert_called_with("compiled", "dummy.coffee")
self.assertEqual(compiler.write_output.call_count, 1)
compiler.write_output.assert_called_with("compiled", "dummy.coffee")
self.assertEqual(compiler.update_dependencies.call_count, 0)
compiler.supports_dependencies = True
compiler.compile("dummy.coffee")
compiler.find_dependencies.assert_called_with("dummy.coffee")
compiler.update_dependencies.assert_called_with("dummy.coffee", ["A", "B"])