You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
716 B

  1. from django.test import TestCase
  2. from hc.lib.string import replace
  3. class StringTestCase(TestCase):
  4. def test_it_works(self):
  5. result = replace("$A is $B", {"$A": "aaa", "$B": "bbb"})
  6. self.assertEqual(result, "aaa is bbb")
  7. def test_it_ignores_placeholders_in_values(self):
  8. result = replace("$A is $B", {"$A": "$B", "$B": "$A"})
  9. self.assertEqual(result, "$B is $A")
  10. def test_it_ignores_overlapping_placeholders(self):
  11. result = replace("$$AB", {"$A": "", "$B": "text"})
  12. self.assertEqual(result, "$B")
  13. def test_it_preserves_non_placeholder_dollar_signs(self):
  14. result = replace("$3.50", {"$A": "text"})
  15. self.assertEqual(result, "$3.50")