def test_replacement__omitted(self): replacer = __unit__.replace(self.SIMPLE_NEEDLE) self._assertReplacer(replacer, [self.SIMPLE_NEEDLE])
def test_needle__empty_iterable(self): with self.assertRaises(ValueError) as r: __unit__.replace([]) self.assertIn("empty", str(r.exception))
def test_needle__list(self): replacer = __unit__.replace(self.LIST_NEEDLE) self._assertReplacer(replacer, self.LIST_NEEDLE)
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)
def test_needle__non_string(self): with self.assertRaises(TypeError): __unit__.replace(object())
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})
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))
def test_replacement__param__none(self): replacer = __unit__.replace(self.SIMPLE_NEEDLE, with_=None) self._assertReplacer(replacer, [self.SIMPLE_NEEDLE])
def test_replacement__param__empty_string(self): replacer = __unit__.replace(self.SIMPLE_NEEDLE, with_="") self._assertReplacer(replacer, {self.SIMPLE_NEEDLE: ""})
def test_needle__mapping(self): replacer = __unit__.replace(self.MAP_REPLACEMENTS) self._assertReplacer(replacer, self.MAP_REPLACEMENTS)
def test_replacement__omitted(self): replacer = __unit__.replace(self.SIMPLE_NEEDLE) self._assertReplacer(replacer, [self.SIMPLE_NEEDLE])
def test_needle__list(self): replacer = __unit__.replace(self.LIST_NEEDLE) self._assertReplacer(replacer, self.LIST_NEEDLE)
def test_needle__some_string(self): replacer = __unit__.replace(self.SIMPLE_NEEDLE) self._assertReplacer(replacer, [self.SIMPLE_NEEDLE])
def test_needle__empty_iterable(self): with self.assertRaises(ValueError) as r: __unit__.replace([]) self.assertIn("empty", str(r.exception))
def test_replacement__param__empty_string(self): replacer = __unit__.replace(self.SIMPLE_NEEDLE, with_="") self._assertReplacer(replacer, {self.SIMPLE_NEEDLE: ""})
def test_replacement__fluent__none(self): with self.assertRaises(TypeError): __unit__.replace(self.SIMPLE_NEEDLE).with_(None)
def test_replacement__fluent__non_string(self): with self.assertRaises(TypeError): __unit__.replace(self.SIMPLE_NEEDLE).with_(object())
def test_replacement__fluent__non_string(self): with self.assertRaises(TypeError): __unit__.replace(self.SIMPLE_NEEDLE).with_(object())
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})
def test_replacement__fluent__empty_string(self): replacer = __unit__.replace(self.SIMPLE_NEEDLE).with_("") self._assertReplacer(replacer, {self.SIMPLE_NEEDLE: ""})
def test_haystack__fluent__empty_string(self): result = __unit__.replace(self.SIMPLE_NEEDLE, with_=self.SIMPLE_REPLACEMENT).in_("") self.assertEquals("", result)
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})
def test_replace__list(self): result = __unit__.replace(self.LIST_NEEDLE).with_( self.LIST_REPLACEMENT).in_(self.HAYSTACK) self.assertEquals(self.LIST_RESULT, result)
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)
def test_needle__non_string(self): with self.assertRaises(TypeError): __unit__.replace(object())
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})
def test_needle__some_string(self): replacer = __unit__.replace(self.SIMPLE_NEEDLE) self._assertReplacer(replacer, [self.SIMPLE_NEEDLE])
def test_haystack__param__empty_string(self): result = __unit__.replace( self.SIMPLE_REPLACEMENT, with_=self.SIMPLE_REPLACEMENT, in_="") self.assertEquals("", result)
def test_needle__mapping(self): replacer = __unit__.replace(self.MAP_REPLACEMENTS) self._assertReplacer(replacer, self.MAP_REPLACEMENTS)
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))
def test_replacement__param__none(self): replacer = __unit__.replace(self.SIMPLE_NEEDLE, with_=None) self._assertReplacer(replacer, [self.SIMPLE_NEEDLE])
def test_haystack__fluent__non_string(self): with self.assertRaises(TypeError): __unit__.replace(self.SIMPLE_NEEDLE, with_=self.SIMPLE_REPLACEMENT).in_(object())
def test_replacement__fluent__none(self): with self.assertRaises(TypeError): __unit__.replace(self.SIMPLE_NEEDLE).with_(None)
def test_haystack__fluent__empty_string(self): result = __unit__.replace( self.SIMPLE_NEEDLE, with_=self.SIMPLE_REPLACEMENT).in_("") self.assertEquals("", result)
def test_replacement__fluent__empty_string(self): replacer = __unit__.replace(self.SIMPLE_NEEDLE).with_("") self._assertReplacer(replacer, {self.SIMPLE_NEEDLE: ""})
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)
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)
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)
def test_haystack__param__empty_string(self): result = __unit__.replace(self.SIMPLE_REPLACEMENT, with_=self.SIMPLE_REPLACEMENT, in_="") self.assertEquals("", result)
def test_replace__simple(self): result = __unit__.replace( self.SIMPLE_NEEDLE).with_( self.SIMPLE_REPLACEMENT).in_(self.HAYSTACK) self.assertEquals(self.SIMPLE_RESULT, result)
def test_haystack__fluent__non_string(self): with self.assertRaises(TypeError): __unit__.replace(self.SIMPLE_NEEDLE, with_=self.SIMPLE_REPLACEMENT).in_(object())
def test_replace__list(self): result = __unit__.replace( self.LIST_NEEDLE).with_( self.LIST_REPLACEMENT).in_(self.HAYSTACK) self.assertEquals(self.LIST_RESULT, result)
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)
def test_replace__mapping(self): result = __unit__.replace(self.MAP_REPLACEMENTS).in_(self.HAYSTACK) self.assertEquals(self.MAP_RESULT, result)
def test_replace__simple(self): result = __unit__.replace(self.SIMPLE_NEEDLE).with_( self.SIMPLE_REPLACEMENT).in_(self.HAYSTACK) self.assertEquals(self.SIMPLE_RESULT, result)
def test_needle__none(self): with self.assertRaises(TypeError) as r: __unit__.replace(None) self.assertIn("None", str(r.exception))
def test_replace__mapping(self): result = __unit__.replace(self.MAP_REPLACEMENTS).in_(self.HAYSTACK) self.assertEquals(self.MAP_RESULT, result)
def test_needle__none(self): with self.assertRaises(TypeError) as r: __unit__.replace(None) self.assertIn("None", str(r.exception))