本文整理汇总了Python中movie.Movie.get_title方法的典型用法代码示例。如果您正苦于以下问题:Python Movie.get_title方法的具体用法?Python Movie.get_title怎么用?Python Movie.get_title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类movie.Movie
的用法示例。
在下文中一共展示了Movie.get_title方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestMovie
# 需要导入模块: from movie import Movie [as 别名]
# 或者: from movie.Movie import get_title [as 别名]
class TestMovie(unittest.TestCase):
"""Tests for movie objects"""
def setUp(self):
self.movie = Movie('../test.mkv')
def test_get_extension(self):
self.assertEqual('.mkv', self.movie.get_extension())
def test_get_filename(self):
self.assertEqual('test', self.movie.get_filename())
def test_get_title(self):
self.assertEqual(None, self.movie.get_title())
def test_get_duration(self):
self.assertEqual('0:21:37', self.movie.get_duration())
示例2: TestMovieClass
# 需要导入模块: from movie import Movie [as 别名]
# 或者: from movie.Movie import get_title [as 别名]
class TestMovieClass(unittest.TestCase):
def setUp(self):
self.m = Movie("Best.Movie.Ever.", 2014, 10)
def test_get_movie_title(self):
self.assertEqual("Best.Movie.Ever.", self.m.get_title())
def test_get_movie_year(self):
self.assertEqual(2014, self.m.get_year())
def test_get_movie_rating(self):
self.assertEqual(10, self.m.get_rating())
@unittest.skip("This works but no point in generating extra movies.")
def test_save_movie(self):
self.assertTrue(self.m.save())
示例3: MovieCatalogProgram
# 需要导入模块: from movie import Movie [as 别名]
# 或者: from movie.Movie import get_title [as 别名]
class MovieCatalogProgram():
def __init__(self):
self.actors = []
self.movies = OrderedDict()
self.db_path = sqlite3.connect("movie_catalog.db")
self.cursor = self.db_path.cursor()
self._load_initial_state()
def add_movie(self):
self.movie_title = input('title >')
self.movie_year = input('year >')
while True:
self.movie_rating = int(input('rating >'))
if self.movie_rating <= 10 and self.movie_rating > 0:
break
else:
print("Rating can only be a number between 1 and 10.")
self.m = Movie(self.movie_title,
self.movie_year,
self.movie_rating)
if(self.m.get_title() not in self.movies.keys()
and self.m.get_year() not in self.movies.values()):
self.movies[self.movie_title] = self.movie_year
self.m.save()
print('{} ({}) {}'.format(self.movie_title,
self.movie_year,
'was added to your catalog!'))
else:
print('Movie already exists!')
def add_actor(self, *arguments):
arguments = list(arguments)
if len(arguments) == 1:
self.name = input('name >')
self.a = Actor(self.name)
self.actors.append(self.name)
arguments.append(len(self.actors))
self.a.save()
else:
if len(self.actors) >= int(arguments[1]):
self.a = Actor(self.actors[int(arguments[1]) - 1])
else:
print("There is no actor with this id! Add new actor!")
self.name = input('name >')
self.a = Actor(self.name)
self.actors.append(self.name)
self.a.save()
self.cursor.execute("""CREATE TABLE IF NOT EXISTS relations
(movie_id, actor_id)""")
query = ("INSERT INTO relations(movie_id, actor_id) VALUES (?, ?)")
data = [int(arguments[0]), int(arguments[1])]
self.cursor.execute(query, data)
self.db_path.commit()
def list_movies(self):
i = 1
for movie in self.movies:
print('[{}] {} ({})'.format(str(i), movie, self.movies[movie]))
i += 1
def list_actors(self):
i = 1
for actor in self.actors:
print('[{}] {}'.format(str(i), actor))
i += 1
def actor_info(self, id):
self.__id = id
movies_ids = []
movies_actor_is_in = []
lines = []
query = ("SELECT Name FROM actors WHERE id = ?")
data = [self.__id]
actor = self.cursor.execute(query, data)
for line in actor:
actor_name = line[0]
query = ("SELECT movie_id FROM relations WHERE actor_id = ?")
for line in self.cursor.execute(query, data):
movies_ids.append(line[0])
for i in range(len(movies_ids)):
query = ("SELECT * FROM movies WHERE id = ?")
data = [movies_ids[i]]
movies_actor_is_in.append(self.cursor.execute(query, data))
for movie_actor_is_in in movies_actor_is_in:
for line in movies_actor_is_in:
for data in line:
lines.append(data)
break
print('{} stars in:'.format(actor_name))
for line in lines:
print('[{}] {} ({})'.format(line[0], line[1], line[2]))
def movie_info(self, id):
self.__id = id
query = ("SELECT * FROM movies WHERE id = ?")
data = [self.__id]
movie = self.cursor.execute(query, data)
actors_ids = []
cast = []
#.........这里部分代码省略.........