示例#1
0
 def test_replacement__omitted(self):
     replacer = __unit__.replace(self.SIMPLE_NEEDLE)
     self._assertReplacer(replacer, [self.SIMPLE_NEEDLE])
示例#2
0
 def test_needle__empty_iterable(self):
     with self.assertRaises(ValueError) as r:
         __unit__.replace([])
     self.assertIn("empty", str(r.exception))
示例#3
0
 def test_needle__list(self):
     replacer = __unit__.replace(self.LIST_NEEDLE)
     self._assertReplacer(replacer, self.LIST_NEEDLE)
示例#4
0
 def test_haystack__duplicate__double_fluent(self):
     result = __unit__.replace(self.SIMPLE_NEEDLE,
                               with_=self.SIMPLE_REPLACEMENT).in_(
                                   self.HAYSTACK)
     with self._assertRaisesAttributeError('in_'):
         result.in_(self.HAYSTACK)
示例#5
0
 def test_needle__non_string(self):
     with self.assertRaises(TypeError):
         __unit__.replace(object())
示例#6
0
 def test_replacement__fluent__some_string(self):
     replacer = __unit__.replace(self.SIMPLE_NEEDLE).with_(
         self.SIMPLE_REPLACEMENT)
     self._assertReplacer(replacer,
                          {self.SIMPLE_NEEDLE: self.SIMPLE_REPLACEMENT})
示例#7
0
 def test_haystack__fluent__none(self):
     with self.assertRaises(TypeError) as r:
         __unit__.replace(self.SIMPLE_NEEDLE,
                          with_=self.SIMPLE_REPLACEMENT).in_(None)
     self.assertIn("None", str(r.exception))
示例#8
0
 def test_replacement__param__none(self):
     replacer = __unit__.replace(self.SIMPLE_NEEDLE, with_=None)
     self._assertReplacer(replacer, [self.SIMPLE_NEEDLE])
示例#9
0
 def test_replacement__param__empty_string(self):
     replacer = __unit__.replace(self.SIMPLE_NEEDLE, with_="")
     self._assertReplacer(replacer, {self.SIMPLE_NEEDLE: ""})
示例#10
0
 def test_needle__mapping(self):
     replacer = __unit__.replace(self.MAP_REPLACEMENTS)
     self._assertReplacer(replacer, self.MAP_REPLACEMENTS)
示例#11
0
 def test_replacement__omitted(self):
     replacer = __unit__.replace(self.SIMPLE_NEEDLE)
     self._assertReplacer(replacer, [self.SIMPLE_NEEDLE])
示例#12
0
 def test_needle__list(self):
     replacer = __unit__.replace(self.LIST_NEEDLE)
     self._assertReplacer(replacer, self.LIST_NEEDLE)
示例#13
0
 def test_needle__some_string(self):
     replacer = __unit__.replace(self.SIMPLE_NEEDLE)
     self._assertReplacer(replacer, [self.SIMPLE_NEEDLE])
示例#14
0
 def test_needle__empty_iterable(self):
     with self.assertRaises(ValueError) as r:
         __unit__.replace([])
     self.assertIn("empty", str(r.exception))
示例#15
0
 def test_replacement__param__empty_string(self):
     replacer = __unit__.replace(self.SIMPLE_NEEDLE, with_="")
     self._assertReplacer(replacer, {self.SIMPLE_NEEDLE: ""})
示例#16
0
 def test_replacement__fluent__none(self):
     with self.assertRaises(TypeError):
         __unit__.replace(self.SIMPLE_NEEDLE).with_(None)
示例#17
0
 def test_replacement__fluent__non_string(self):
     with self.assertRaises(TypeError):
         __unit__.replace(self.SIMPLE_NEEDLE).with_(object())
示例#18
0
 def test_replacement__fluent__non_string(self):
     with self.assertRaises(TypeError):
         __unit__.replace(self.SIMPLE_NEEDLE).with_(object())
示例#19
0
 def test_haystack__param__none(self):
     replacer = __unit__.replace(self.SIMPLE_NEEDLE,
                                 with_=self.SIMPLE_REPLACEMENT,
                                 in_=None)
     self._assertReplacer(replacer,
                          {self.SIMPLE_NEEDLE: self.SIMPLE_REPLACEMENT})
示例#20
0
 def test_replacement__fluent__empty_string(self):
     replacer = __unit__.replace(self.SIMPLE_NEEDLE).with_("")
     self._assertReplacer(replacer, {self.SIMPLE_NEEDLE: ""})
示例#21
0
 def test_haystack__fluent__empty_string(self):
     result = __unit__.replace(self.SIMPLE_NEEDLE,
                               with_=self.SIMPLE_REPLACEMENT).in_("")
     self.assertEquals("", result)
示例#22
0
 def test_replacement__fluent__some_string(self):
     replacer = __unit__.replace(
         self.SIMPLE_NEEDLE).with_(self.SIMPLE_REPLACEMENT)
     self._assertReplacer(replacer,
                          {self.SIMPLE_NEEDLE: self.SIMPLE_REPLACEMENT})
示例#23
0
 def test_replace__list(self):
     result = __unit__.replace(self.LIST_NEEDLE).with_(
         self.LIST_REPLACEMENT).in_(self.HAYSTACK)
     self.assertEquals(self.LIST_RESULT, result)
示例#24
0
 def test_replacement__duplicate__double_fluent(self):
     replacer = __unit__.replace(
         self.SIMPLE_NEEDLE).with_(self.SIMPLE_REPLACEMENT)
     with self.assertRaises(__unit__.ReplacementError):
         replacer.with_(self.SIMPLE_REPLACEMENT)
示例#25
0
 def test_needle__non_string(self):
     with self.assertRaises(TypeError):
         __unit__.replace(object())
示例#26
0
 def test_haystack__param__none(self):
     replacer = __unit__.replace(
         self.SIMPLE_NEEDLE, with_=self.SIMPLE_REPLACEMENT, in_=None)
     self._assertReplacer(replacer,
                          {self.SIMPLE_NEEDLE: self.SIMPLE_REPLACEMENT})
示例#27
0
 def test_needle__some_string(self):
     replacer = __unit__.replace(self.SIMPLE_NEEDLE)
     self._assertReplacer(replacer, [self.SIMPLE_NEEDLE])
示例#28
0
 def test_haystack__param__empty_string(self):
     result = __unit__.replace(
         self.SIMPLE_REPLACEMENT, with_=self.SIMPLE_REPLACEMENT, in_="")
     self.assertEquals("", result)
示例#29
0
 def test_needle__mapping(self):
     replacer = __unit__.replace(self.MAP_REPLACEMENTS)
     self._assertReplacer(replacer, self.MAP_REPLACEMENTS)
示例#30
0
 def test_haystack__fluent__none(self):
     with self.assertRaises(TypeError) as r:
         __unit__.replace(
             self.SIMPLE_NEEDLE, with_=self.SIMPLE_REPLACEMENT).in_(None)
     self.assertIn("None", str(r.exception))
示例#31
0
 def test_replacement__param__none(self):
     replacer = __unit__.replace(self.SIMPLE_NEEDLE, with_=None)
     self._assertReplacer(replacer, [self.SIMPLE_NEEDLE])
示例#32
0
 def test_haystack__fluent__non_string(self):
     with self.assertRaises(TypeError):
         __unit__.replace(self.SIMPLE_NEEDLE,
                          with_=self.SIMPLE_REPLACEMENT).in_(object())
示例#33
0
 def test_replacement__fluent__none(self):
     with self.assertRaises(TypeError):
         __unit__.replace(self.SIMPLE_NEEDLE).with_(None)
示例#34
0
 def test_haystack__fluent__empty_string(self):
     result = __unit__.replace(
         self.SIMPLE_NEEDLE, with_=self.SIMPLE_REPLACEMENT).in_("")
     self.assertEquals("", result)
示例#35
0
 def test_replacement__fluent__empty_string(self):
     replacer = __unit__.replace(self.SIMPLE_NEEDLE).with_("")
     self._assertReplacer(replacer, {self.SIMPLE_NEEDLE: ""})
示例#36
0
 def test_haystack__fluent__some_string(self):
     result = __unit__.replace(
         self.SIMPLE_NEEDLE,
         with_=self.SIMPLE_REPLACEMENT).in_(self.HAYSTACK)
     self.assertEquals(self.SIMPLE_RESULT, result)
示例#37
0
 def test_replacement__duplicate__double_fluent(self):
     replacer = __unit__.replace(self.SIMPLE_NEEDLE).with_(
         self.SIMPLE_REPLACEMENT)
     with self.assertRaises(__unit__.ReplacementError):
         replacer.with_(self.SIMPLE_REPLACEMENT)
示例#38
0
 def test_haystack__duplicate__double_fluent(self):
     result = __unit__.replace(
         self.SIMPLE_NEEDLE, with_=self.SIMPLE_REPLACEMENT).in_(
         self.HAYSTACK)
     with self._assertRaisesAttributeError('in_'):
         result.in_(self.HAYSTACK)
示例#39
0
 def test_haystack__param__empty_string(self):
     result = __unit__.replace(self.SIMPLE_REPLACEMENT,
                               with_=self.SIMPLE_REPLACEMENT,
                               in_="")
     self.assertEquals("", result)
示例#40
0
 def test_replace__simple(self):
     result = __unit__.replace(
         self.SIMPLE_NEEDLE).with_(
         self.SIMPLE_REPLACEMENT).in_(self.HAYSTACK)
     self.assertEquals(self.SIMPLE_RESULT, result)
示例#41
0
 def test_haystack__fluent__non_string(self):
     with self.assertRaises(TypeError):
         __unit__.replace(self.SIMPLE_NEEDLE,
                          with_=self.SIMPLE_REPLACEMENT).in_(object())
示例#42
0
 def test_replace__list(self):
     result = __unit__.replace(
         self.LIST_NEEDLE).with_(
         self.LIST_REPLACEMENT).in_(self.HAYSTACK)
     self.assertEquals(self.LIST_RESULT, result)
示例#43
0
 def test_haystack__fluent__some_string(self):
     result = __unit__.replace(self.SIMPLE_NEEDLE,
                               with_=self.SIMPLE_REPLACEMENT).in_(
                                   self.HAYSTACK)
     self.assertEquals(self.SIMPLE_RESULT, result)
示例#44
0
 def test_replace__mapping(self):
     result = __unit__.replace(self.MAP_REPLACEMENTS).in_(self.HAYSTACK)
     self.assertEquals(self.MAP_RESULT, result)
示例#45
0
 def test_replace__simple(self):
     result = __unit__.replace(self.SIMPLE_NEEDLE).with_(
         self.SIMPLE_REPLACEMENT).in_(self.HAYSTACK)
     self.assertEquals(self.SIMPLE_RESULT, result)
示例#46
0
 def test_needle__none(self):
     with self.assertRaises(TypeError) as r:
         __unit__.replace(None)
     self.assertIn("None", str(r.exception))
示例#47
0
 def test_replace__mapping(self):
     result = __unit__.replace(self.MAP_REPLACEMENTS).in_(self.HAYSTACK)
     self.assertEquals(self.MAP_RESULT, result)
示例#48
0
 def test_needle__none(self):
     with self.assertRaises(TypeError) as r:
         __unit__.replace(None)
     self.assertIn("None", str(r.exception))