Код: Выделить всё
"""A collection of functions for working with cities."""
def city_country(city, country):
"""Return a string like 'Santiago, Chile'."""
return f"{city().title}, {country().title}"
Имя файла: test_test_test
Код: Выделить всё
from city_country_city_functions import city_country
def test_city_country():
"""Does a simple city and country pair work?"""
santiago_chile = city_country('santiago', 'chile')
assert santiago_chile == 'Santiago, Chile'
Вот что появляется:
Код: Выделить всё
___ ERROR collecting test_test_test.py ______________________
../../../.local/lib/python2.7/site-packages/_pytest/python.py:507: in _importtestmodule
mod = self.fspath.pyimport(ensuresyspath=importmode)
../../../.local/lib/python2.7/site-packages/py/_path/local.py:704: in pyimport
__import__(modname)
../../../.local/lib/python2.7/site-packages/_pytest/assertion/rewrite.py:304: in load_module
exec(co, mod.__dict__)
test_test_test.py:1: in
from city_country_city_functions import city_country
E File "/home/magnum/PycharmProjects/pythonProject7/city_country/city_country_city_functions.py", line 5
E return f"{city().title}, {country().title}"
E ^
E SyntaxError: invalid syntax
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.10 second
Подробнее здесь: https://stackoverflow.com/questions/790 ... portant-st
Мобильная версия