コード例 #1
0
    def test_copying_media(self):

        docs_dir = tempfile.mkdtemp()
        site_dir = tempfile.mkdtemp()
        try:
            # Create a markdown file, image, dot file and dot directory.
            open(os.path.join(docs_dir, 'index.md'), 'w').close()
            open(os.path.join(docs_dir, 'img.jpg'), 'w').close()
            open(os.path.join(docs_dir, '.hidden'), 'w').close()
            os.mkdir(os.path.join(docs_dir, '.git'))
            open(os.path.join(docs_dir, '.git/hidden'), 'w').close()

            conf = config.validate_config({
                'site_name': 'Example',
                'docs_dir': docs_dir,
                'site_dir': site_dir
            })
            build.build(conf)

            # Verify only the markdown (coverted to html) and the image are copied.
            self.assertTrue(
                os.path.isfile(os.path.join(site_dir, 'index.html')))
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'img.jpg')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.hidden')))
            self.assertFalse(
                os.path.isfile(os.path.join(site_dir, '.git/hidden')))
        finally:
            shutil.rmtree(docs_dir)
            shutil.rmtree(site_dir)
コード例 #2
0
ファイル: test.py プロジェクト: itech001/mkdocs
    def test_copying_media(self):

        docs_dir = tempfile.mkdtemp()
        site_dir = tempfile.mkdtemp()
        try:
            # Create a markdown file, image, dot file and dot directory.
            open(os.path.join(docs_dir, 'index.md'), 'w').close()
            open(os.path.join(docs_dir, 'img.jpg'), 'w').close()
            open(os.path.join(docs_dir, '.hidden'), 'w').close()
            os.mkdir(os.path.join(docs_dir, '.git'))
            open(os.path.join(docs_dir, '.git/hidden'), 'w').close()

            conf = config.validate_config({
                'site_name': 'Example',
                'docs_dir': docs_dir,
                'site_dir': site_dir
            })
            build.build(conf)

            # Verify only the markdown (coverted to html) and the image are copied.
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'index.html')))
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'img.jpg')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.hidden')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.git/hidden')))
        finally:
            shutil.rmtree(docs_dir)
            shutil.rmtree(site_dir)
コード例 #3
0
ファイル: test.py プロジェクト: jpush/mkdocs
 def test_default_pages(self):
     tmp_dir = tempfile.mkdtemp()
     try:
         open(os.path.join(tmp_dir, "index.md"), "w").close()
         open(os.path.join(tmp_dir, "about.md"), "w").close()
         conf = config.validate_config({"site_name": "Example", "docs_dir": tmp_dir})
         self.assertEqual(conf["pages"], ["index.md", "about.md"])
     finally:
         shutil.rmtree(tmp_dir)
コード例 #4
0
 def test_default_pages(self):
     tmp_dir = tempfile.mkdtemp()
     try:
         open(os.path.join(tmp_dir, 'index.md'), 'w').close()
         open(os.path.join(tmp_dir, 'about.md'), 'w').close()
         conf = config.validate_config({
             'site_name': 'Example',
             'docs_dir': tmp_dir
         })
         self.assertEqual(conf['pages'], ['index.md', 'about.md'])
     finally:
         shutil.rmtree(tmp_dir)
コード例 #5
0
ファイル: test.py プロジェクト: alihalabyah/mkdocs
 def test_default_pages(self):
     tmp_dir = tempfile.mkdtemp()
     try:
         open(os.path.join(tmp_dir, 'index.md'), 'w').close()
         open(os.path.join(tmp_dir, 'about.md'), 'w').close()
         conf = config.validate_config({
             'site_name': 'Example',
             'docs_dir': tmp_dir
         })
         self.assertEqual(conf['pages'], ['index.md', 'about.md'])
     finally:
         shutil.rmtree(tmp_dir)
コード例 #6
0
    def test_copying_media(self):

        docs_dir = tempfile.mkdtemp()
        site_dir = tempfile.mkdtemp()
        try:
            # Create a non-empty markdown file, image, dot file and dot directory.
            f = open(os.path.join(docs_dir, 'index.md'), 'w')
            f.write(
                dedent("""
                page_title: custom title

                # Heading 1

                This is some text.

                # Heading 2

                And some more text.
            """))
            f.close()
            open(os.path.join(docs_dir, 'img.jpg'), 'w').close()
            open(os.path.join(docs_dir, '.hidden'), 'w').close()
            os.mkdir(os.path.join(docs_dir, '.git'))
            open(os.path.join(docs_dir, '.git/hidden'), 'w').close()

            conf = config.validate_config({
                'site_name': 'Example',
                'docs_dir': docs_dir,
                'site_dir': site_dir
            })
            build.build(conf)

            # Verify only the markdown (coverted to html) and the image are copied.
            self.assertTrue(
                os.path.isfile(os.path.join(site_dir, 'index.html')))
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'img.jpg')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.hidden')))
            self.assertFalse(
                os.path.isfile(os.path.join(site_dir, '.git/hidden')))
        finally:
            shutil.rmtree(docs_dir)
            shutil.rmtree(site_dir)
コード例 #7
0
ファイル: build_tests.py プロジェクト: chaabni/mkdocs
    def test_copying_media(self):

        docs_dir = tempfile.mkdtemp()
        site_dir = tempfile.mkdtemp()
        try:
            # Create a non-empty markdown file, image, dot file and dot directory.
            f = open(os.path.join(docs_dir, 'index.md'), 'w')
            f.write(dedent("""
                page_title: custom title

                # Heading 1

                This is some text.

                # Heading 2

                And some more text.
            """))
            f.close()
            open(os.path.join(docs_dir, 'img.jpg'), 'w').close()
            open(os.path.join(docs_dir, '.hidden'), 'w').close()
            os.mkdir(os.path.join(docs_dir, '.git'))
            open(os.path.join(docs_dir, '.git/hidden'), 'w').close()

            conf = config.validate_config({
                'site_name': 'Example',
                'docs_dir': docs_dir,
                'site_dir': site_dir
            })
            build.build(conf)

            # Verify only the markdown (coverted to html) and the image are copied.
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'index.html')))
            self.assertTrue(os.path.isfile(os.path.join(site_dir, 'img.jpg')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.hidden')))
            self.assertFalse(os.path.isfile(os.path.join(site_dir, '.git/hidden')))
        finally:
            shutil.rmtree(docs_dir)
            shutil.rmtree(site_dir)
コード例 #8
0
 def load_missing_site_name():
     config.validate_config({})
コード例 #9
0
ファイル: test.py プロジェクト: alihalabyah/mkdocs
 def load_missing_site_name():
     config.validate_config({})