Пример #1
0
 def test_replace_link_img_matches_replaces_multiple_escaped_right_parens(
         self):
     image = u"![](image \(\(\(1\)\)\).jpg)"
     expected = u"![](image \(\(\(1))).jpg)"
     result = utility.replace_link_img_matches(self.right_paren_regex,
                                               ")", image)
     self.assertEqual(expected, result)
Пример #2
0
 def test_replace_link_img_matches_replace_left_paren_with_char_entity(
         self):
     image = u"![](image \(1\).jpg)"
     expected = u"![](image (1\).jpg)"
     result = utility.replace_link_img_matches(self.left_paren_regex,
                                               "(", image)
     self.assertEqual(expected, result)
Пример #3
0
    def test_replace_link_img_matches_does_not_replace_whitespace_in_code_blocks_but_does_in_normal_link(
            self):
        image = u"""
        hallo `welerd

```
hello world [](what about it) yes
```

but here ![cat](cat (1).jpg) is a cat
and`
"""
        expected = u"""
        hallo `welerd

```
hello world [](what about it) yes
```

but here ![cat](cat (1).jpg) is a cat
and`
"""
        result = utility.replace_link_img_matches(self.whitespace_regex,
                                                  " ", image)
        self.assertEqual(expected, result)
        self.assertEqual(len(expected), len(result))
 def test_replace_link_img_matches_replaces_whitespace_in_different_parts(self):
     image               = u"![](image \(1\) .jpg)"
     expected            = u"![](image \(1\) .jpg)"
     result = utility.replace_link_img_matches(self.whitespace_regex,
                                               " ",
                                               image)
     self.assertEqual(expected, result)
Пример #5
0
 def test_replace_link_img_matches_makes_no_changes_when_final_paren_is_missing(
         self):
     image = u"[](image \(1\).jpg"
     expected = u"[](image \(1\).jpg"
     result = utility.replace_link_img_matches(self.whitespace_regex,
                                               " ", image)
     self.assertEqual(expected, result)
Пример #6
0
 def test_replace_link_img_matches_replaces_link_with_title_that_contains_whitespace(
         self):
     image = u"[random text](image \(1\).jpg)"
     expected = u"[random text](image \(1\).jpg)"
     result = utility.replace_link_img_matches(self.whitespace_regex,
                                               " ", image)
     self.assertEqual(expected, result)
Пример #7
0
 def test_replace_link_img_matches_returns_same_when_whitespace_before_opening_paren(
         self):
     image = u"![] (image \(1\).jpg)"
     expected = u"![] (image \(1\).jpg)"
     result = utility.replace_link_img_matches(self.whitespace_regex,
                                               " ", image)
     self.assertEqual(expected, result)
Пример #8
0
 def test_replace_link_img_matches_does_not_replace_unescaped_left_parens(
         self):
     image = u"[](image (1\).jpg"
     expected = u"[](image (1\).jpg"
     result = utility.replace_link_img_matches(self.left_paren_regex,
                                               " ", image)
     self.assertEqual(expected, result)
 def test_replace_link_img_matches_accepts_russian_input(self):
     image       = u"![](изображение \(1\).jpg)"
     expected    = u"![](изображение \(1\).jpg)"
     result      = utility.replace_link_img_matches(self.whitespace_regex,
                                                    " ",
                                                    image)
     self.assertEqual(expected, result)
Пример #10
0
 def test_replace_link_img_matches_replaces_whitespace_in_different_parts(
         self):
     image = u"![](image \(1\) .jpg)"
     expected = u"![](image \(1\) .jpg)"
     result = utility.replace_link_img_matches(self.whitespace_regex,
                                               " ", image)
     self.assertEqual(expected, result)
    def test_replace_link_img_matches_does_not_replace_whitespace_in_code_blocks_but_does_in_normal_link(self):
        image       = u"""
        hallo `welerd

```
hello world [](what about it) yes
```

but here ![cat](cat (1).jpg) is a cat
and`
"""
        expected    = u"""
        hallo `welerd

```
hello world [](what about it) yes
```

but here ![cat](cat (1).jpg) is a cat
and`
"""
        result = utility.replace_link_img_matches(self.whitespace_regex,
                                                  " ",
                                                  image)
        self.assertEqual(expected, result)
        self.assertEqual(len(expected), len(result))
 def test_replace_link_img_matches_replace_multiple_left_parens_with_char_entity(self):
     image               = u"![](image \(\(\(1\)\)\).jpg)"
     expected            = u"![](image (((1\)\)\).jpg)"
     result = utility.replace_link_img_matches(self.left_paren_regex,
                                               "(",
                                               image)
     self.assertEqual(expected, result)
 def test_replace_link_img_matches_replaces_multiple_escaped_right_parens(self):
     image               = u"![](image \(\(\(1\)\)\).jpg)"
     expected            = u"![](image \(\(\(1))).jpg)"
     result = utility.replace_link_img_matches(self.right_paren_regex,
                                               ")",
                                               image)
     self.assertEqual(expected, result)
 def test_replace_link_img_matches_does_not_replace_whitespace_in_backticks(self):
     image       = u"begin `def x[R](f: => R)` end"
     expected    = u"begin `def x[R](f: => R)` end"
     result = utility.replace_link_img_matches(self.whitespace_regex,
                                               " ",
                                               image)
     self.assertEqual(expected, result)
     self.assertEqual(len(expected), len(result))
Пример #15
0
 def test_replace_link_img_matches_does_not_replace_whitespace_in_backticks(
         self):
     image = u"begin `def x[R](f: => R)` end"
     expected = u"begin `def x[R](f: => R)` end"
     result = utility.replace_link_img_matches(self.whitespace_regex,
                                               " ", image)
     self.assertEqual(expected, result)
     self.assertEqual(len(expected), len(result))
Пример #16
0
 def test_replace_link_img_matches_replaces_whitespace_and_parens_in_multiple_imgs(
         self):
     image       = u"random text before\n" + \
                   u"![](image \(1\).jpg)\n" + \
                   u"and more text\n" + \
                   u"![](image \(2\).jpg)"
     expected    = u"random text before\n" + \
                   u"![](image (1).jpg)\n" + \
                   u"and more text\n" + \
                   u"![](image (2).jpg)"
     result = utility.replace_link_img_matches(self.whitespace_regex,
                                               " ", image)
     result = utility.replace_link_img_matches(self.left_paren_regex,
                                               "(", result)
     result = utility.replace_link_img_matches(self.right_paren_regex,
                                               ")", result)
     self.assertEqual(expected, result)
     self.assertEqual(len(expected), len(result))
 def test_replace_link_img_matches_replaces_whitespace_and_parens_in_multiple_imgs(self):
     image       = u"random text before\n" + \
                   u"![](image \(1\).jpg)\n" + \
                   u"and more text\n" + \
                   u"![](image \(2\).jpg)"
     expected    = u"random text before\n" + \
                   u"![](image (1).jpg)\n" + \
                   u"and more text\n" + \
                   u"![](image (2).jpg)"
     result = utility.replace_link_img_matches(self.whitespace_regex,
                                               " ",
                                               image)
     result = utility.replace_link_img_matches(self.left_paren_regex,
                                               "(",
                                               result)
     result = utility.replace_link_img_matches(self.right_paren_regex,
                                               ")",
                                               result)
     self.assertEqual(expected, result)
     self.assertEqual(len(expected), len(result))
    def test_replace_link_img_matches_does_not_replace_whitespace_in_code_blocks2(self):
        image       = u"""
blah

```
def x[R](f: => R)
```
"""
        expected    = image
        result = utility.replace_link_img_matches(self.whitespace_regex,
                                                  " ",
                                                  image)
        self.assertEqual(expected, result)
        self.assertEqual(len(expected), len(result))
Пример #19
0
    def test_replace_link_img_matches_does_not_replace_whitespace_in_code_blocks2(
            self):
        image = u"""
blah

```
def x[R](f: => R)
```
"""
        expected = image
        result = utility.replace_link_img_matches(self.whitespace_regex,
                                                  " ", image)
        self.assertEqual(expected, result)
        self.assertEqual(len(expected), len(result))
Пример #20
0
    def test_replace_link_img_matches_does_not_replace_whitespace_in_code_blocks(
            self):
        image = u"""
        hallo `welerd

```
hello world [](what about it) yes
```

and`
"""
        expected = image
        result = utility.replace_link_img_matches(self.whitespace_regex,
                                                  " ", image)
        self.assertEqual(expected, result)
        self.assertEqual(len(expected), len(result))
    def test_replace_link_img_matches_does_not_replace_whitespace_in_code_blocks(self):
        image       = u"""
        hallo `welerd

```
hello world [](what about it) yes
```

and`
"""
        expected    = image
        result = utility.replace_link_img_matches(self.whitespace_regex,
                                                  " ",
                                                  image)
        self.assertEqual(expected, result)
        self.assertEqual(len(expected), len(result))
 def test_replace_link_img_matches_replaces_link_with_whitespace(self):
     image               = u"[](image \(1\).jpg)"
     expected            = u"[](image \(1\).jpg)"
     result = utility.replace_link_img_matches(self.whitespace_regex, " ", image)
     self.assertEqual(expected, result)
 def test_replace_link_img_matches_replaces_link_with_title_that_contains_whitespace(self):
     image               = u"[random text](image \(1\).jpg)"
     expected            = u"[random text](image \(1\).jpg)"
     result = utility.replace_link_img_matches(self.whitespace_regex, " ", image)
     self.assertEqual(expected, result)
 def test_replace_link_img_matches_makes_no_changes_when_final_paren_is_missing(self):
     image               = u"[](image \(1\).jpg"
     expected            = u"[](image \(1\).jpg"
     result = utility.replace_link_img_matches(self.whitespace_regex, " ", image)
     self.assertEqual(expected, result)
 def test_replace_link_img_matches_does_not_replace_unescaped_left_parens(self):
     image               = u"[](image (1\).jpg"
     expected            = u"[](image (1\).jpg"
     result = utility.replace_link_img_matches(self.left_paren_regex, " ", image)
     self.assertEqual(expected, result)
Пример #26
0
 def test_replace_link_img_matches_replaces_link_with_whitespace(self):
     image = u"[](image \(1\).jpg)"
     expected = u"[](image \(1\).jpg)"
     result = utility.replace_link_img_matches(self.whitespace_regex,
                                               " ", image)
     self.assertEqual(expected, result)
Пример #27
0
 def test_replace_link_img_matches_accepts_russian_input(self):
     image = u"![](изображение \(1\).jpg)"
     expected = u"![](изображение \(1\).jpg)"
     result = utility.replace_link_img_matches(self.whitespace_regex,
                                               " ", image)
     self.assertEqual(expected, result)
 def test_replace_link_img_matches_returns_same_when_whitespace_before_opening_paren(self):
     image               = u"![] (image \(1\).jpg)"
     expected            = u"![] (image \(1\).jpg)"
     result = utility.replace_link_img_matches(self.whitespace_regex, " ", image)
     self.assertEqual(expected, result)