(self)
| 151 | self.assertTStringEqual(t, ("", r"\Documents"), [(path, "path")]) |
| 152 | |
| 153 | def test_template_concatenation(self): |
| 154 | # Test template + template |
| 155 | t1 = t"Hello, " |
| 156 | t2 = t"world" |
| 157 | combined = t1 + t2 |
| 158 | self.assertTStringEqual(combined, ("Hello, world",), ()) |
| 159 | self.assertEqual(fstring(combined), "Hello, world") |
| 160 | |
| 161 | # Test template + string |
| 162 | t1 = t"Hello" |
| 163 | expected_msg = 'can only concatenate string.templatelib.Template ' \ |
| 164 | '\\(not "str"\\) to string.templatelib.Template' |
| 165 | with self.assertRaisesRegex(TypeError, expected_msg): |
| 166 | t1 + ", world" |
| 167 | |
| 168 | # Test template + template with interpolation |
| 169 | name = "Python" |
| 170 | t1 = t"Hello, " |
| 171 | t2 = t"{name}" |
| 172 | combined = t1 + t2 |
| 173 | self.assertTStringEqual(combined, ("Hello, ", ""), [(name, "name")]) |
| 174 | self.assertEqual(fstring(combined), "Hello, Python") |
| 175 | |
| 176 | # Test string + template |
| 177 | expected_msg = 'can only concatenate str ' \ |
| 178 | '\\(not "string.templatelib.Template"\\) to str' |
| 179 | with self.assertRaisesRegex(TypeError, expected_msg): |
| 180 | "Hello, " + t"{name}" |
| 181 | |
| 182 | def test_nested_templates(self): |
| 183 | # Test a template inside another template expression |
nothing calls this directly
no test coverage detected