コード例 #1
0
 def test_Pmwiki2MdUnderscoreConversion(self):
     from lib.pmwiki2md import Conversions, Pmwiki2MdUnderscoreBeginConversion, Pmwiki2MdUnderscoreEndConversion
     original = Content("Cucumbers {+might+} be tomatoes.")
     shouldLookLike = ["Cucumbers ", "''", "might", "''", " be tomatoes."]
     conversions = Conversions(Pmwiki2MdUnderscoreBeginConversion,
                               Pmwiki2MdUnderscoreEndConversion)
     self.compareMultiConverted(original, shouldLookLike, conversions)
コード例 #2
0
 def test_Pmwiki2MdSuperscriptConversion(self):
     from lib.pmwiki2md import Pmwiki2MdSuperscriptConversion as Conversion
     original = Content("Cucumbers '^might^' be tomatoes.")
     shouldLookLike = [
         "Cucumbers ", "<sup>", "might", "</sup>", " be tomatoes."
     ]
     self.compareConverted(original, shouldLookLike, Conversion)
コード例 #3
0
 def test_Pmwiki2MdStrikethroughConversion(self):
     from lib.pmwiki2md import Conversions, Pmwiki2MdStrikethroughBeginConversion, Pmwiki2MdStrikethroughEndConversion
     original = Content("Cucumbers {-might-} be tomatoes.")
     shouldLookLike = ["Cucumbers ", "~~", "might", "~~", " be tomatoes."]
     conversions = Conversions(Pmwiki2MdStrikethroughBeginConversion,
                               Pmwiki2MdStrikethroughEndConversion)
     self.compareMultiConverted(original, shouldLookLike, conversions)
コード例 #4
0
 def test_Pmwiki2MdImageUrlConversion(self):
     from lib.pmwiki2md import Pmwiki2MdImageUrlConversion as Conversion
     original = Content("[[http://example.com/example.png]]")
     shouldLookLike = [
         "![", "Example", "]", "(", "http://example.com/example.png", ")"
     ]
     cdprint(Conversion().convert(original))
     self.compareConverted(original, shouldLookLike, Conversion)
コード例 #5
0
 def test_Pmwiki2MdSmallSmallConversion(self):
     from lib.pmwiki2md import Conversions, Pmwiki2MdSmallSmallBeginConversion, Pmwiki2MdSmallSmallEndConversion
     original = Content("Cucumbers [--might--] be tomatoes.")
     shouldLookLike = [
         "Cucumbers ", "<sub>", "might", "</sub>", " be tomatoes."
     ]
     conversions = Conversions(Pmwiki2MdSmallSmallBeginConversion,
                               Pmwiki2MdSmallSmallEndConversion)
     self.compareMultiConverted(original, shouldLookLike, conversions)
コード例 #6
0
 def test_Pmwiki2MdBigBigsConversion(self):
     from lib.pmwiki2md import Conversions, Pmwiki2MdBigBigBeginConversion, Pmwiki2MdBigBigEndConversion
     original = Content("Cucumbers [++might++] be tomatoes.")
     shouldLookLike = [
         "Cucumbers ", "<sup>", "might", "</sup>", " be tomatoes."
     ]
     conversions = Conversions(Pmwiki2MdBigBigBeginConversion,
                               Pmwiki2MdBigBigEndConversion)
     self.compareMultiConverted(original, shouldLookLike, conversions)
コード例 #7
0
    def test_ConversionOfBeginEndDelimitedToSomething(self):

        from lib.pmwiki2md import ConversionOfBeginEndDelimitedToSomething

        class Conversion(ConversionOfBeginEndDelimitedToSomething):

            BEGIN = "[["
            END = "]]"

        original = Content("[[a]] [[b]]")
        shouldLookLike = ["[[", "a", "]]", " ", "[[", "b", "]]"]
        self.compareConverted(original, shouldLookLike, Conversion)
コード例 #8
0
    def test_ConversionByIterativeSingleCodeReplacementAtBeginOfLine_highestLevel(
            self):
        from lib.pmwiki2md import ConversionByIterativeSingleCodeReplacementAtBeginOfLine

        class __Test(ConversionByIterativeSingleCodeReplacementAtBeginOfLine):
            OLD = "*"
            NEW = "-"

        toBeCounted = Content(
            "\n*X\n**XXXX\n*\n*******XXX\n**XXXXXXXX\n****XX")
        countShouldBe = 7
        count = __Test().highestLevel(toBeCounted)
        self.assertEqual(count, countShouldBe)
コード例 #9
0
 def _runOneFileTest(self, filePair):
     from lib.pmwiki2md import AllConversions as Conversions, Content as Content
     conversions = Conversions()
     pmwikiFilePath = os.path.join(self.pmwikiConversionsBaseDir,
                                   "testTest.pmwiki")
     mdFilePath = self.getMatchingMdFilePathForPmwikiFilePath(
         pmwikiFilePath)
     testFilePair = TestFilePair(pmwikiFilePath, mdFilePath)
     dprint("testFilePair", testFilePair.pmwikiFilePath,
            testFilePair.mdFilePath)
     return self.assertEqual(
         conversions.convert(Content(testFilePair.pmwiki)).string,
         testFilePair.md)
コード例 #10
0
 def test_ContentCopy(self):
     from lib.pmwiki2md import Content
     content1 = Content()
     content1.append("a")
     content1Copy = content1.copy()
     content2 = Content()
     self.assertEqual(content1, ["a"])
     self.assertEqual(content2, [])
コード例 #11
0
 def convert(self):
     for pair in self.filePairs:
         converted = self.conversions().convert(Content(pair.source.read()))
         pair.target.write(converted.string)
コード例 #12
0
 def test_Pmwiki2MdTitle3Conversion(self):
     from lib.pmwiki2md import Pmwiki2MdTitle3Conversion as Conversion
     original = Content("\n!!!Cucumbers might be tomatoes.")
     shouldLookLike = ["", "\n### ", "Cucumbers might be tomatoes."]
     self.compareConverted(original, shouldLookLike, Conversion)
コード例 #13
0
 def test_Pmwiki2Md3LevelBulletListConversion(self):
     from lib.pmwiki2md import Pmwiki2MdBulletListConversion as Conversion
     original = Content("\n***Cucumbers might be tomatoes.")
     shouldLookLike = ["", "\n      - ", "Cucumbers might be tomatoes."]
     self.compareConverted(original, shouldLookLike, Conversion)
コード例 #14
0
 def test_Pmwiki2MdNamelessLinkPointyBracketsConversion(self):
     from lib.pmwiki2md import Pmwiki2MdLinkConversion as Conversion
     original = Content("[[http://example.com]]")
     shouldLookLike = ["<", "http://example.com", ">"]
     self.compareConverted(original, shouldLookLike, Conversion)
コード例 #15
0
 def test_Pmwiki2MdNamedLinkConversion(self):
     from lib.pmwiki2md import Pmwiki2MdLinkConversion as Conversion
     original = Content("[[http://example.com | Example]]")
     shouldLookLike = ["[", "Example", "]", "(", "http://example.com", ")"]
     cdprint(Conversion().convert(original))
     self.compareConverted(original, shouldLookLike, Conversion)
コード例 #16
0
 def test_Pmwiki2MdBoldConversion(self):
     from lib.pmwiki2md import Pmwiki2MdBoldConversion as Conversion
     original = Content("Cucumbers '''might''' be tomatoes.")
     shouldLookLike = ["Cucumbers ", "__", "might", "__", " be tomatoes."]
     self.compareConverted(original, shouldLookLike, Conversion)
コード例 #17
0
 def test_Pmwiki2MdPreFormattedInlineConversion(self):
     from lib.pmwiki2md import Pmwiki2MdPreFormattedInlineConversion as Conversion
     original = Content("[@Cucumbers *might* be tomatoes.@]")
     shouldLookLike = ["`", "Cucumbers *might* be tomatoes.", "`"]
     cdprint(Conversion().convert(original))
     self.compareConverted(original, shouldLookLike, Conversion)
コード例 #18
0
 def runOneFileTest(self, pmwikiFileTestName):
     from lib.pmwiki2md import AllConversions as Conversions, Content as Content
     testFilePair = self.filePairs[pmwikiFileTestName]
     conversions = Conversions()
     content = Content(testFilePair.pmwiki)
     return self.convertAndCompare(conversions, content, testFilePair)