26. Alat PengembanganΒΆ
Modul yang dijelaskan dalam bab ini membantu Anda menulis perangkat lunak. Sebagai contoh, modul pydoc
mengambil modul dan menghasilkan dokumentasi berdasarkan isi modul. Modul doctest
dan unittest
berisi kerangka kerja untuk penulisan unit test yang secara otomatis menjalankan kode dan memverifikasi bahwa output yang diharapkan dihasilkan. 2to3 dapat menerjemahkan kode Python 2.x menjadi kode Python 3.x yang valid.
Daftar modul yang dijelaskan di dalam bab ini adalah:
- 26.1.
typing
--- Support for type hints - 26.2.
pydoc
--- Documentation generator and online help system - 26.3.
doctest
--- Test interactive Python examples - 26.4.
unittest
--- Unit testing framework- 26.4.1. Contoh dasar
- 26.4.2. Command-Line Interface
- 26.4.3. Test Discovery
- 26.4.4. Organizing test code
- 26.4.5. Re-using old test code
- 26.4.6. Skipping tests and expected failures
- 26.4.7. Distinguishing test iterations using subtests
- 26.4.8. Classes and functions
- 26.4.9. Class and Module Fixtures
- 26.4.10. Penanganan Sinyal Signal
- 26.5.
unittest.mock
--- mock object library - 26.6.
unittest.mock
--- getting started- 26.6.1. Using Mock
- 26.6.1.1. Mock Patching Methods
- 26.6.1.2. Mock for Method Calls on an Object
- 26.6.1.3. Mocking Classes
- 26.6.1.4. Naming your mocks
- 26.6.1.5. Tracking all Calls
- 26.6.1.6. Setting Return Values and Attributes
- 26.6.1.7. Raising exceptions with mocks
- 26.6.1.8. Side effect functions and iterables
- 26.6.1.9. Creating a Mock from an Existing Object
- 26.6.2. Patch Decorators
- 26.6.3. Further Examples
- 26.6.3.1. Mocking chained calls
- 26.6.3.2. Partial mocking
- 26.6.3.3. Mocking a Generator Method
- 26.6.3.4. Applying the same patch to every test method
- 26.6.3.5. Mocking Unbound Methods
- 26.6.3.6. Checking multiple calls with mock
- 26.6.3.7. Coping with mutable arguments
- 26.6.3.8. Nesting Patches
- 26.6.3.9. Mocking a dictionary with MagicMock
- 26.6.3.10. Mock subclasses and their attributes
- 26.6.3.11. Mocking imports with patch.dict
- 26.6.3.12. Tracking order of calls and less verbose call assertions
- 26.6.3.13. More complex argument matching
- 26.6.1. Using Mock
- 26.7. 2to3 - Automated Python 2 to 3 code translation
- 26.8.
test
--- Regression tests package for Python - 26.9.
test.support
--- Utilities for the Python test suite