выдает ошибку Failed test - test_5[carrying-Nissan-f1.jpg-1-5]. E AssertionError: Тест 5.2. Атрибут carrying экземпляра класса Car должен возвращать объект типа: float. assert False + where False = isinstance('1', <class 'float'>) + where '1' = getattr(<solution.Car object at 0x7fc3f5b5f0f0>, 'carrying')
import csv
import os.path
TYPE_CAR = 'car'
TYPE_TRUCK = 'truck'
TYPE_SPEC_MACHINE = 'spec_machine'
class CarBase:
def __init__(self, car_type, brand, photo_file_name, carrying):
self.car_type = car_type
self.photo_file_name = photo_file_name
self.brand = brand
self.carrying = carrying
def set_photo_file_name(self, filename):
self.photo_file_name = filename
def set_brand(self, brand):
self.brand = brand
def set_carrying(self, carrying):
self.carrying = float(carrying)
def get_photo_file_ext(self):
return os.path.splitext(self.photo_file_name)[1]
class Car(CarBase):
def __init__(self, brand, photo_file_name, carrying, passenger_seats_count):
super().__init__(TYPE_CAR, brand, photo_file_name, carrying)
self.passenger_seats_count = passenger_seats_count
def set_passenger_seats_count(self, count):
self.passenger_seats_count = int(count)
class Truck(CarBase):
def __init__(self, brand, photo_file_name, carrying, passenger_seats_count):
super().__init__(TYPE_CAR, brand, photo_file_name, carrying)
self.passenger_seats_count = passenger_seats_count
def set_body_width(self, width):
self.body_width = float(width)
def set_body_height(self, height):
self.body_height = float(height)
def set_body_length(self, length):
self.body_length = float(length)
def get_body_volume(self):
return self.body_width * self.body_height * self.body_length
class SpecMachine(CarBase):
def __init__(self, brand, photo_file_name, carrying, passenger_seats_count):
super().__init__(TYPE_CAR, brand, photo_file_name, carrying)
self.passenger_seats_count = passenger_seats_count
def set_extra(self, extra):
self.extra = extra
def parse_row(row):
brand = row[1]
photo_file_name = row[3]
carrying = row[5]
if row[0] == TYPE_CAR:
car = Car(brand, photo_file_name, carrying, row[2])
def get_car_list(filename):
cars = list()
with open(filename) as csv_fd:
reader = csv.reader(csv_fd, delimiter=';')
next(reader) # skip csv header
for row in reader:
car = parse_row(row)
if car is not None:
cars.append(car)
return cars