当前位置: 首页>>代码示例>>Python>>正文


Python cmdline.main函数代码示例

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


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

示例1: test_post_with_date

    def test_post_with_date(self):
        cmdline.main(["--post", "Dated Post", "--date", "2011/11/20"])

        file_path = os.path.join(utils.TEST_ROOT, "2011/11/20", "dated_post.rst")

        # assert file exists
        self.assertTrue(os.path.exists(file_path))
开发者ID:dhellmann,项目名称:tinkerer,代码行数:7,代码来源:test_cmdline.py

示例2: test_draft

    def test_draft(self):
        cmdline.main(["--draft", "My Draft", "--quiet"])

        file_path = os.path.join(utils.TEST_ROOT, "drafts", "my_draft.rst")

        # assert draft was created
        self.assertTrue(os.path.exists(file_path))
开发者ID:Brother-Simon,项目名称:tinkerer,代码行数:7,代码来源:test_cmdline.py

示例3: test_page_from_title

    def test_page_from_title(self):
        cmdline.main(["--page", "My Test Page", "--quiet"])

        file_path = os.path.join(utils.TEST_ROOT, "pages", "my_test_page.rst")

        # assert file exsits
        self.assertTrue(os.path.exists(file_path))
开发者ID:Brother-Simon,项目名称:tinkerer,代码行数:7,代码来源:test_cmdline.py

示例4: test_date_only_on_post

    def test_date_only_on_post(self):
        self.assertNotEqual(0,
                cmdline.main(["--page", "Test Page", "--date", "2011/11/20"]))

        self.assertNotEqual(0,
                cmdline.main(["--draft", "Test Draft", "--date", "2011/11/20"]))

        self.assertNotEqual(0,
                cmdline.main(["--build", "--date", "2011/11/20"]))
开发者ID:dhellmann,项目名称:tinkerer,代码行数:9,代码来源:test_cmdline.py

示例5: test_post_from_title

    def test_post_from_title(self):
        cmdline.main(["--post", "My Test Post", "--quiet"])

        # this might fail at midnight :P
        year, month, day = tinkerer.utils.split_date()

        file_path = os.path.join(utils.TEST_ROOT, year, month, day, "my_test_post.rst")

        # assert file exists
        self.assertTrue(os.path.exists(file_path))
开发者ID:dhellmann,项目名称:tinkerer,代码行数:10,代码来源:test_cmdline.py

示例6: test_setup

    def test_setup(self):
        # blog is setup as part of test setup, tear it down and re-create it via
        # cmdline
        self.tearDown()
        cmdline.main(["--setup", "--quiet"])

        self.assertEqual(
            set(os.listdir(utils.TEST_ROOT)),
            set(["_static", "_templates", "drafts", "conf.py", "index.html", tinkerer.master_doc + ".rst"]),
        )
开发者ID:johnnywsd,项目名称:tinkerer,代码行数:10,代码来源:test_cmdline.py

示例7: test_root_only

    def test_root_only(self):
        # remove "conf.py" created by test setup
        os.remove(os.path.join(paths.root, "conf.py"))

        self.assertNotEqual(0, cmdline.main(["--page", "Test Post", "--quiet"]))

        self.assertNotEqual(0, cmdline.main(["--post", "Test Page", "--quiet"]))

        self.assertNotEqual(0, cmdline.main(["--build", "--quiet"]))

        # setup should work fine from anywhere
        self.assertEqual(0, cmdline.main(["--setup", "--quiet"]))
开发者ID:johnnywsd,项目名称:tinkerer,代码行数:12,代码来源:test_cmdline.py

示例8: test_filename_only

    def test_filename_only(self):
        # hook up test log handler
        test_stream = StringIO()

        # restore logging for this particular test
        logging.disable(logging.NOTSET)

        output.filename.addHandler(logging.StreamHandler(test_stream))

        # setup new blog with --filename flag
        cmdline.main(["--setup", "--filename"])

        # output should be `conf.py`
        self.assertEquals("conf.py", test_stream.getvalue().strip())
开发者ID:Brother-Simon,项目名称:tinkerer,代码行数:14,代码来源:test_cmdline.py

示例9: test_post_from_existing_file

    def test_post_from_existing_file(self):
        # create file
        draft_file = os.path.join(utils.TEST_ROOT, "drafts", "draft_page.rst")

        with open(draft_file, "w") as f:
            f.write("Content")

        cmdline.main(["--page", draft_file, "--quiet"])

        file_path = os.path.join(utils.TEST_ROOT, "pages", "draft_page.rst")

        # assert file exists and check content
        self.assertTrue(os.path.exists(file_path))
        with open(file_path, "r") as f:
            self.assertEquals("Content", f.read())
开发者ID:Brother-Simon,项目名称:tinkerer,代码行数:15,代码来源:test_cmdline.py

示例10: test_missing_template

 def test_missing_template(self):
     # creating a post with a missing template file should fail
     self.assertNotEqual(
         0,
         cmdline.main(["--post", "test", "--template", "missing",
                       "--quiet"])
     )
开发者ID:Brother-Simon,项目名称:tinkerer,代码行数:7,代码来源:test_cmdline.py

示例11: test_post_from_path

    def test_post_from_path(self):
        # create file
        draft_file = os.path.join(utils.TEST_ROOT, "drafts", "draft_post.rst")

        with open(draft_file, "w") as f:
            f.write("Content")

        cmdline.main(["--post", draft_file, "--quiet"])

        # this might also fail at midnight :P
        year, month, day = tinkerer.utils.split_date()

        file_path = os.path.join(utils.TEST_ROOT, year, month, day, "draft_post.rst")

        # assert file exists and check content
        self.assertTrue(os.path.exists(file_path))
        with open(file_path, "r") as f:
            self.assertEquals("Content", f.read())
开发者ID:dhellmann,项目名称:tinkerer,代码行数:18,代码来源:test_cmdline.py

示例12: test_setup

    def test_setup(self):
        # blog is setup as part of test setup, tear it down and
        # re-create it via cmdline
        self.tearDown()
        cmdline.main(["--setup", "--quiet"])

        self.assertEqual(
            set(os.listdir(utils.TEST_ROOT)),
            set([
                "_static",
                "_templates",
                "drafts",
                "conf.py",
                "index.html",
                tinkerer.master_doc + ".rst"
            ]))

        # favicon should be copied to the blog _static folder
        self.assertTrue(os.path.exists(
            os.path.join(utils.TEST_ROOT, "_static", paths.favicon)
            ))
开发者ID:Brother-Simon,项目名称:tinkerer,代码行数:21,代码来源:test_cmdline.py

示例13: test_preview

    def test_preview(self):
        # create a post
        new_post = post.create("A post", datetime.datetime(2010, 10, 1))

        # post should be in master doc (precondition)
        lines = master.read_master()
        self.assertTrue("   %s\n" % new_post.docname in lines)

        # create a draft
        new_draft = draft.create("draft")
        self.assertTrue(os.path.exists(new_draft))

        # preview it (build should succeed)
        self.assertEqual(0, cmdline.main(["--preview", new_draft, "-q"]))

        # draft should not be in TOC
        for line in master.read_master():
            self.assertFalse("draft" in line)
开发者ID:johnnywsd,项目名称:tinkerer,代码行数:18,代码来源:test_draft.py

示例14:

from tinkerer import cmdline
import sys

cmdline.main(sys.argv[1:])

开发者ID:jcrudy,项目名称:jcrudy.github.io,代码行数:4,代码来源:main.py


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