my sample django project works fine and i get result but the problem is that whenever i run unit test on my project i get syntax error as follows in test.py. i have tried using .format() still it shows up error .why cant i use f'this is my text' to format my string ? error log
ERROR: blog.tests (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: blog.tests
Traceback (most recent call last):
File "/usr/lib/python3.5/unittest/loader.py", line 428, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.5/unittest/loader.py", line 369, in
_get_module_from_name
__import__(name)
File "/home/blog/tests.py", line 28
self.assertEqual(f'{self.post.title}', 'Content')
^
SyntaxError: invalid syntax
f-strings are valid in Python 3.6+ only.
However there doesn't seem to be any reason to use them here, since you're not interpolating anything. Why not just self.assertEqual(self.post.title, 'Content')
?