def test_replace_strings(self): """ Test replace string with convention """ content = self._open_file("test_comments.js") result = jscompiler.replace_strings(content) self.assertIsInstance(result, tuple) self.assertEqual(len(result), 2) self.assertIsInstance(result[0], str) self.assertIsInstance(result[1], list) # test_comments.js contains two string self.assertEquals(len(result[1]), 2) self.assertRegexpMatches(result[0], r"__\{\d+\}__") self.assertEquals(len(re.findall(r"__\{\d+\}__", result[0])), 2)
def test_put_strings(self): """ Test the opposite of replace_strings """ content = self._open_file("test_comments.js") new_content, str_all = jscompiler.replace_strings(content) # First arg self.assertIsNotNone(new_content) self.assertIsInstance(new_content, str) self.assertNotEqual(len(content), 0) # Second arg self.assertIsInstance(str_all, list) self.assertNotEqual(len(str_all), 0) # put put_content = jscompiler.put_strings(new_content, str_all) self.assertEqual(content, put_content)