當前位置: 首頁>>代碼示例>>Python>>正文


Python locator.Locator類代碼示例

本文整理匯總了Python中pystache.locator.Locator的典型用法代碼示例。如果您正苦於以下問題:Python Locator類的具體用法?Python Locator怎麽用?Python Locator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Locator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的pystache.locator.Locator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。