from movie import Movie
def run_tests():
enter code here
print("Test empty movie:")
default_movie = Movie()
print(default_movie)
assert default_movie.title == ""
assert default_movie.category == ""
assert default_movie.year == 0
assert not default_movie.is_watched
initial_movie = Movie("Thor: Ragnarok", 2017, "Comedy", True)
run_tests()
Is it possible to create a class that can be instantiated like this? I've came across and I don't know the solution to this. The class needs to have an init and str constructors
This is what I came so far
class Movie:
def __init__(self, title, year, category, is_watched):
self.title = title
self.year = year
self.category = category
self.is_watched = is_watched
def __str__(self):
return 'movie=> {} {} {} {} {}'.format(self.name, self.year, self.genre, self.is_watched)
#sw = Movie("SW", 1977, "action", 0);
#print(sw);
But when I run the test file regarding this class, a error is thrown
TypeError: init() missing 4 required positional arguments: 'title', 'year', 'category', and 'is_watched'
Movie("", 0, "", False).