当前位置: 首页>>代码示例>>Python>>正文


Python Library.remove_book方法代码示例

本文整理汇总了Python中library.Library.remove_book方法的典型用法代码示例。如果您正苦于以下问题:Python Library.remove_book方法的具体用法?Python Library.remove_book怎么用?Python Library.remove_book使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在library.Library的用法示例。


在下文中一共展示了Library.remove_book方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: removeBook

# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import remove_book [as 别名]
    def removeBook(self):
        """
            Use the entered information if it is valid in order to remove the
            book after the Add button is pushed.
        """
        data = [self.titleEdit.text(), self.authorEdit.text(), self.yearEdit.text(), self.genre_options.currentText()]

        invalid_data = Validations.check_all(*data)
        if invalid_data == []:
            book = Book(
                self.titleEdit.text(),
                self.authorEdit.text(),
                self.yearEdit.text(),
                self.genre_options.currentText(),
                0,
                0,
            )
            Library.remove_book(book)
            self.label.setText("You removed the book successfully!")
        else:
            message = "Unsuccessful removal!Invalid:\n"
            message += "\n".join(invalid_data)
            self.label.setText(message)
        for edit in (self.titleEdit, self.authorEdit, self.yearEdit):
            edit.clear()
开发者ID:Ralitsa-Ts,项目名称:Bookstore_and_Chart,代码行数:27,代码来源:remove_book.py

示例2: test_duplicate_books

# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import remove_book [as 别名]
 def test_duplicate_books(self):
     testlib = Library()
     testlib.add_book(576.82, 'A New History of Life')
     testlib.add_book(576.82, 'A New History of Life')
     assert len(testlib.shelves[5].books) == 2
     testlib.remove_book(576.82)
     assert len(testlib.shelves[5].books) == 1
开发者ID:angwinner,项目名称:gingersnap,代码行数:9,代码来源:library_unittest.py

示例3: test_number_of_different_books

# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import remove_book [as 别名]
 def test_number_of_different_books(self):
     Library(self.store, ["Fantasy", "Thriller"])
     self.add_books([self.books[0], self.books[1], self.books[2]], Library)
     self.assertEqual(3, Library.number_of_different_books())
     Library.add_book(self.books[0])
     self.assertEqual(3, Library.number_of_different_books())
     Library.remove_book(self.books[1])
     self.assertEqual(2, Library.number_of_different_books())
     os.remove(os.path.realpath(self.store))
开发者ID:Ralitsa-Ts,项目名称:Bookstore_and_Chart,代码行数:11,代码来源:library_tests.py

示例4: test_remove_book

# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import remove_book [as 别名]
 def test_remove_book(self):
     testlib = Library()
     testlib.add_book(576.82, 'A New History of Life')
     testlib.add_book(575.01, 'An Old History of Life')
     assert len(testlib.shelves[5].books) == 2
     testlib.remove_book(576.82)
     assert len(testlib.shelves[5].books) == 1
     # remove nonexistent book
     testlib.remove_book(501.2)
     assert len(testlib.shelves[5].books) == 1
开发者ID:angwinner,项目名称:gingersnap,代码行数:12,代码来源:library_unittest.py

示例5: test_number_of_books_by_genres

# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import remove_book [as 别名]
 def test_number_of_books_by_genres(self):
     Library(self.store, ["Fantasy", "Thriller"])
     self.add_books([self.books[0], self.books[1], self.books[2]], Library)
     actual_result = Library.number_of_books_by_genres()
     self.assertEqual({'Fantasy': 2, 'Thriller': 1}, actual_result)
     Library.add_book(self.books[3])
     actual_result = Library.number_of_books_by_genres()
     self.assertEqual({'Fantasy': 2, 'Thriller': 2}, actual_result)
     Library.remove_book(self.books[1])
     actual_result = Library.number_of_books_by_genres()
     self.assertEqual({'Fantasy': 1, 'Thriller': 2}, actual_result)
     Library.remove_book(self.books[0])
     actual_result = Library.number_of_books_by_genres()
     self.assertEqual({'Fantasy': 0, 'Thriller': 2}, actual_result)
     os.remove(os.path.realpath(self.store))
开发者ID:Ralitsa-Ts,项目名称:Bookstore_and_Chart,代码行数:17,代码来源:library_tests.py

示例6: test_remove_book

# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import remove_book [as 别名]
 def test_remove_book(self):
     Library(self.store, ["Fantasy", "Thriller"])
     self.add_books([self.books[0], self.books[1], self.books[1]], Library)
     Library.remove_book(self.books[0])
     self.assertEqual([self.books[1]], Library.books)
     Library.remove_book(self.books[0])
     self.assertNotEqual([], Library.books)
     Library.remove_book(self.books[1])
     self.assertEqual([], Library.books)
     os.remove(os.path.realpath(self.store))
开发者ID:Ralitsa-Ts,项目名称:Bookstore_and_Chart,代码行数:12,代码来源:library_tests.py


注:本文中的library.Library.remove_book方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。