• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python locator.Locator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pystache.locator.Locator的典型用法代码示例。如果您正苦于以下问题:Python Locator类的具体用法?Python Locator怎么用?Python Locator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_get_object_directory

    def test_get_object_directory(self):
        locator = Locator()

        obj = SayHello()
        actual = locator.get_object_directory(obj)

        self.assertEquals(actual, os.path.abspath(DATA_DIR))
开发者ID:clach04,项目名称:pystache,代码行数:7,代码来源:test_locator.py


示例2: test_get_object_directory

    def test_get_object_directory(self):
        locator = Locator()

        obj = SayHello()
        actual = locator.get_object_directory(obj)

        self._assert_paths(actual, DATA_DIR)
开发者ID:SvetlanaM,项目名称:EnabledCityPaloAlto,代码行数:7,代码来源:test_locator.py


示例3: test_find_object

    def test_find_object(self):
        locator = Locator()

        obj = SayHello()

        actual = locator.find_object(search_dirs=[], obj=obj, file_name='sample_view.mustache')
        expected = os.path.join(DATA_DIR, 'sample_view.mustache')

        self._assert_paths(actual, expected)
开发者ID:SvetlanaM,项目名称:EnabledCityPaloAlto,代码行数:9,代码来源:test_locator.py


示例4: test_get_object_directory__not_hasattr_module

    def test_get_object_directory__not_hasattr_module(self):
        locator = Locator()

        obj = datetime(2000, 1, 1)
        self.assertFalse(hasattr(obj, "__module__"))
        self.assertEquals(locator.get_object_directory(obj), None)

        self.assertFalse(hasattr(None, "__module__"))
        self.assertEquals(locator.get_object_directory(None), None)
开发者ID:clach04,项目名称:pystache,代码行数:9,代码来源:test_locator.py


示例5: test_find_object__none_file_name

    def test_find_object__none_file_name(self):
        locator = Locator()

        obj = SayHello()

        actual = locator.find_object(search_dirs=[], obj=obj)
        expected = os.path.abspath(os.path.join(DATA_DIR, "say_hello.mustache"))

        self.assertEquals(actual, expected)
开发者ID:clach04,项目名称:pystache,代码行数:9,代码来源:test_locator.py


示例6: test_get_object_directory

    def test_get_object_directory(self):
        locator = Locator()

        reader = Reader()
        actual = locator.get_object_directory(reader)

        expected = os.path.join(os.path.dirname(__file__), os.pardir, 'pystache')

        self.assertEquals(os.path.normpath(actual), os.path.normpath(expected))
开发者ID:jakearchibald,项目名称:pystache,代码行数:9,代码来源:test_locator.py


示例7: test_find_object__none_object_directory

    def test_find_object__none_object_directory(self):
        locator = Locator()

        obj = None
        self.assertEquals(None, locator.get_object_directory(obj))

        actual = locator.find_object(search_dirs=[DATA_DIR], obj=obj, file_name="say_hello.mustache")
        expected = os.path.join(DATA_DIR, "say_hello.mustache")

        self.assertEquals(actual, expected)
开发者ID:clach04,项目名称:pystache,代码行数:10,代码来源:test_locator.py


示例8: test_make_template_name

    def test_make_template_name(self):
        """
        Test make_template_name().

        """
        locator = Locator()

        class FooBar(object):
            pass
        foo = FooBar()

        self.assertEqual(locator.make_template_name(foo), 'foo_bar')
开发者ID:SvetlanaM,项目名称:EnabledCityPaloAlto,代码行数:12,代码来源:test_locator.py


示例9: test_find_name__precedence

    def test_find_name__precedence(self):
        """
        Test the order in which find_name() searches directories.

        """
        locator = Locator()

        dir1 = DATA_DIR
        dir2 = LOCATOR_DATA_DIR

        self.assertTrue(locator.find_name(search_dirs=[dir1], template_name='duplicate'))
        self.assertTrue(locator.find_name(search_dirs=[dir2], template_name='duplicate'))

        path = locator.find_name(search_dirs=[dir2, dir1], template_name='duplicate')
        dirpath = os.path.dirname(path)
        dirname = os.path.split(dirpath)[-1]

        self.assertEqual(dirname, 'locator')
开发者ID:SvetlanaM,项目名称:EnabledCityPaloAlto,代码行数:18,代码来源:test_locator.py


示例10: test_locate_path__precedence

    def test_locate_path__precedence(self):
        """
        Test the order in which locate_path() searches directories.

        """
        locator = Locator()

        dir1 = DATA_DIR
        dir2 = os.path.join(DATA_DIR, 'locator')

        self.assertTrue(locator.locate_path('duplicate', search_dirs=[dir1]))
        self.assertTrue(locator.locate_path('duplicate', search_dirs=[dir2]))

        path = locator.locate_path('duplicate', search_dirs=[dir2, dir1])
        dirpath = os.path.dirname(path)
        dirname = os.path.split(dirpath)[-1]

        self.assertEquals(dirname, 'locator')
开发者ID:jakearchibald,项目名称:pystache,代码行数:18,代码来源:test_locator.py


示例11: test_find_name__precedence

    def test_find_name__precedence(self):
        """
        Test the order in which find_name() searches directories.

        """
        locator = Locator()

        dir1 = DATA_DIR
        dir2 = os.path.join(DATA_DIR, "locator")

        self.assert_(locator.find_name(search_dirs=[dir1], template_name="duplicate"))
        self.assert_(locator.find_name(search_dirs=[dir2], template_name="duplicate"))

        path = locator.find_name(search_dirs=[dir2, dir1], template_name="duplicate")
        dirpath = os.path.dirname(path)
        dirname = os.path.split(dirpath)[-1]

        self.assertEquals(dirname, "locator")
开发者ID:clach04,项目名称:pystache,代码行数:18,代码来源:test_locator.py


示例12: test_get_object_directory__not_hasattr_module

    def test_get_object_directory__not_hasattr_module(self):
        locator = Locator()

        # Previously, we used a genuine object -- a datetime instance --
        # because datetime instances did not have the __module__ attribute
        # in CPython.  See, for example--
        #
        #   http://bugs.python.org/issue15223
        #
        # However, since datetime instances do have the __module__ attribute
        # in PyPy, we needed to switch to something else once we added
        # support for PyPi.  This was so that our test runs would pass
        # in all systems.
        obj = "abc"
        self.assertFalse(hasattr(obj, '__module__'))
        self.assertEqual(locator.get_object_directory(obj), None)

        self.assertFalse(hasattr(None, '__module__'))
        self.assertEqual(locator.get_object_directory(None), None)
开发者ID:SvetlanaM,项目名称:EnabledCityPaloAlto,代码行数:19,代码来源:test_locator.py


示例13: test_make_file_name

    def test_make_file_name(self):
        locator = Locator()

        locator.template_extension = "bar"
        self.assertEquals(locator.make_file_name("foo"), "foo.bar")

        locator.template_extension = False
        self.assertEquals(locator.make_file_name("foo"), "foo")

        locator.template_extension = ""
        self.assertEquals(locator.make_file_name("foo"), "foo.")
开发者ID:clach04,项目名称:pystache,代码行数:11,代码来源:test_locator.py


示例14: test_make_file_name

    def test_make_file_name(self):
        locator = Locator()

        locator.template_extension = 'bar'
        self.assertEqual(locator.make_file_name('foo'), 'foo.bar')

        locator.template_extension = False
        self.assertEqual(locator.make_file_name('foo'), 'foo')

        locator.template_extension = ''
        self.assertEqual(locator.make_file_name('foo'), 'foo.')
开发者ID:SvetlanaM,项目名称:EnabledCityPaloAlto,代码行数:11,代码来源:test_locator.py


示例15: test_make_file_name__template_extension_argument

    def test_make_file_name__template_extension_argument(self):
        locator = Locator()

        self.assertEqual(locator.make_file_name('foo', template_extension='bar'), 'foo.bar')
开发者ID:SvetlanaM,项目名称:EnabledCityPaloAlto,代码行数:4,代码来源:test_locator.py


示例16: test_find_name__using_list_of_paths

    def test_find_name__using_list_of_paths(self):
        locator = Locator()
        path = locator.find_name(search_dirs=["doesnt_exist", "examples"], template_name="simple")

        self.assert_(path)
开发者ID:clach04,项目名称:pystache,代码行数:5,代码来源:test_locator.py


示例17: test_find_name

    def test_find_name(self):
        locator = Locator()
        path = locator.find_name(search_dirs=["examples"], template_name="simple")

        self.assertEquals(os.path.basename(path), "simple.mustache")
开发者ID:clach04,项目名称:pystache,代码行数:5,代码来源:test_locator.py


示例18: test_make_file_name__template_extension_argument

    def test_make_file_name__template_extension_argument(self):
        locator = Locator()

        self.assertEquals(locator.make_file_name("foo", template_extension="bar"), "foo.bar")
开发者ID:clach04,项目名称:pystache,代码行数:4,代码来源:test_locator.py


示例19: test_locate_path__using_list_of_paths

    def test_locate_path__using_list_of_paths(self):
        locator = Locator()
        path = locator.locate_path('simple', search_dirs=['doesnt_exist', 'examples'])

        self.assertTrue(path)
开发者ID:jakearchibald,项目名称:pystache,代码行数:5,代码来源:test_locator.py


示例20: test_find_name__using_list_of_paths

    def test_find_name__using_list_of_paths(self):
        locator = Locator()
        path = locator.find_name(search_dirs=[EXAMPLES_DIR, 'doesnt_exist'], template_name='simple')

        self.assertTrue(path)
开发者ID:SvetlanaM,项目名称:EnabledCityPaloAlto,代码行数:5,代码来源:test_locator.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python renderer.Renderer类代码示例发布时间:2022-05-27
下一篇:
Python loader.Loader类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap