Index
A
- Arrange-Act-Assert pattern
- about / Arrange-Act-Assert
- assertEqual, versus assertIs / Exploring assert methods
- assertIn/assertNotIn / Exploring assert methods
- assertIsInstance/assertNotIsInstance / Exploring assert methods
- assert methods
- exploring / Exploring assert methods
- assertAlmostEqual method / Exploring assert methods
- about / Exploring assert methods
- assertRaisesRegex() / Exploring assert methods
- assertWarns() / Exploring assert methods
- assertWarnsRegex() / Exploring assert methods
- attributes
- using / Pattern – using attributes
- using, with vanilla unittests / Attributes with vanilla unittests
B
- better asserts
- writing / Writing better asserts
- brittle tests
- about / Brittle tests
- example / Brittle tests
- guidelines / Brittle tests
- build tools
- integrating with / Integrating with build tools
- Paver / Paver
C
- characterization tests
- about / What are characterization tests?
- writing / Writing a characterization test
- running / The cycle continues
- code smells
- identifying / Identifying code smells
- long methods / Identifying code smells
- unclear naming / Identifying code smells
- complex conditionals / Identifying code smells
- bad comments / Identifying code smells
- magic constants / Identifying code smells
- code duplication / Identifying code smells
- command line
- tests, running / Running tests from the command line
- Commenting Styles refactoring
- about / Commenting Styles
- compatible code
- writing, for multiple Python versions / Writing code that is compatible across versions
- continuous integration tools
- integrating with / Integrating with continuous integration tools
- Jenkins / Jenkins
- Travis CI / Travis CI
- custom equality checkers
- using / Using custom equality checkers
- custom test case class hierarchy
D
- data-driven tests
- about / Pattern – data-driven tests
- example / Pattern – data-driven tests
- debugging
- test failures / Debugging test failures
- dependencies, breaking
- techniques / Techniques to break dependencies
- Rope refactoring library / The Rope refactoring library
- initialization, separating from execution / Separate initialization from execution
- default values, using for parameters / Use default values for parameters
- method, extracting / Extract the method and test
- test, extracting / Extract the method and test
- dependencies, injecting / Inject dependencies
- inheritance, implementing / Inherit and test
- local methods, stubbing / Stubbing local methods
- extract method, stubbing / Extract the method and stub
- design
- refactoring / Refactoring the design
- developer testing
- developer unit testing
- directives, doctest
- about / Doctest directives
- NORMALIZE_WHITESPACE / Doctest directives
- IGNORE_EXCEPTION_DETAIL / Doctest directives
- SKIP / Doctest directives
- REPORT_ONLY_FIRST_FAILURE / Doctest directives
- distutils
- about / Distutils
- docstrings
- about / Using docstrings
- using / Using docstrings
- doctest
- about / Our first doctest
- writing / Our first doctest
- running / Running the doctest, Running a suite of doctests
- maintaining / Maintaining doctests
- setUp method / Setup and teardown
- tearDown method / Setup and teardown
- limitations / Limitations of doctest
- directives / Doctest directives
- implementing, into TDD process / How do doctests fit into the TDD process?
- doctests
- running, with nose2 plugins / Doctest support
- DRY principle
- about / The DRY principle
- dual crossover moving average (DMAC)
- about / A dual crossover moving average
- Buy Signal / A dual crossover moving average
- Sell Signal / A dual crossover moving average
- implementing / Implementing the dual crossover moving average
E
- exceptions
- testing / Testing for exceptions
- expected failures
- about / Pattern – expected failures
- Extract Class refactoring
- about / Extract Class
- Extract Conditional to Method refactoring
- about / Extract Conditional to Method
- Extract Method refactoring
- about / The Extract Method refactoring
F
- fakes
- versus mocks / Mocks versus stubs versus fakes versus spies
- fast tests
- about / Pattern – fast tests
- considerations / Pattern – fast tests
- filesystem layout
- about / Filesystem layout
- fixtures
- using / Using fixtures
- using, with patched mocks / Fixtures and patching
- flowchart, TDD
G
- generated tests
- writing, in nose2 / Generated tests
- generators
- about / Pattern – patching the open function
- reference link / Pattern – patching the open function
H
- helper methods
- writing / Writing helper methods
I
- IDE integration
- about / IDE integration
- installation
- nose2 / Getting started with nose2
- integration testing
- integration tests
- about / Pattern – integration and system tests
- considerations / Pattern – integration and system tests
J
- Jenkins
- about / Jenkins
L
- Layers
- about / Layers
- legacy code
- about / What is legacy code?
- example / Understanding the code
- characterization tests / What are characterization tests?
- Python interactive shell, using / Using the Python interactive shell to understand the code
- characterization tests, writing / Writing a characterization test
- pdb, using / Using pdb to understand the code
- refactoring / Time to refactor
- load_tests protocol
- using / Using the load_tests protocol
- long-term refactoring
- about / Long-term refactoring
M
- matchers
- using / Using matchers
- methods
- patching / Patching methods
- mocks
- writing / Hand writing a simple mock
- best solutions / How much mocking is too much?
- versus stubs / Mocks versus stubs versus fakes versus spies
- versus fakes / Mocks versus stubs versus fakes versus spies
- versus spies / Mocks versus stubs versus fakes versus spies
- example / Tying it all together
- Move Method to Class refactoring
- about / Move Method to Class
- msg parameter
- about / Exploring assert methods
- mutable args
- mocking with / Pattern – mocking with mutable args
N
- naming conventions, tests
- about / Naming conventions
- nose2
- installing / Getting started with nose2
- tests, writing / Writing tests for nose2
- setup function, implementing / Setup and teardown
- teardown function, implementing / Setup and teardown
- parameterized tests, writing / Parameterized tests
- generated tests, writing / Generated tests
- Layers / Layers
- plugins / nose2 plugins
- configuration / nose2 configuration
- versus py.test / py.test versus nose2
O
- objects
- mocking / Mocking objects
- open function
- patching / Pattern – patching the open function
- organization, tests
- about / Organizing tests
- filesystem layout / Filesystem layout
- naming convention / Naming conventions
- test suite, grouping / Test suite grouping
P
- -p file_pattern / Running the tests after the reorganization
- package level doctests
- about / Package-level doctests
- packaging tools
- integrating with / Integrating with packaging tools
- setuptools / Setuptools
- parameterized tests
- writing, in nose2 / Parameterized tests
- patching
- about / Patching methods
- considerations / An important gotcha when patching
- Paver
- about / Paver
- pdb
- using / Using pdb to understand the code
- commands / Some common pdb commands
- implementing / Walking through a pdb session
- plugins, nose2
- about / nose2 plugins
- doctests, running / Doctest support
- test results, writing to XML file / Writing test results to an XML file
- test coverage, measuring / Measuring test coverage
- test failures, debugging / Debugging test failures
- nose2 configuration / nose2 configuration
- py.test
- about / py.test
- features / py.test
- versus nose2 / py.test versus nose2
- URL / py.test versus nose2
- PyHamcrest
- about / PyHamcrest
- URL / PyHamcrest
- Python 2.6
- code examples, running / Running the examples in this book
- Python interactive shell
- Python mocking framework
- about / Using the Python mocking framework
- objects, mocking / Mocking objects
- return values, mocking / Mocking return values
- side effects, mocking / Mocking side effects
- methods, patching / Patching methods
R
- readable tests
- creating / Making tests readable
- docstrings, using / Using docstrings
- fixtures, using / Using fixtures
- fixtures, using with patched mocks / Fixtures and patching
- custom test case class hierarchy, using / Using a custom test case class hierarchy
- refactoring
- about / Refactoring
- Rename Variable / The Rename Variable and Rename Method refactorings
- Rename Method / The Rename Variable and Rename Method refactorings
- Commenting Styles / Commenting Styles
- Replace Magic Literals with Constants / Replace Magic Literals with Constants
- Extract Method / The Extract Method refactoring
- Replace Calculation with Temporary Variable / Replace Calculation with Temporary Variable
- Extract Conditional to Method / Extract Conditional to Method
- DRY principle / The DRY principle
- Single Responsibility Principle (SRP) / Single Responsibility Principle
- Extract Class / Extract Class
- Move Method to Class / Move Method to Class
- legacy code / Time to refactor
- long-term refactoring / Long-term refactoring
- Rename Method refactoring
- Rename Variable refactoring
- Replace Calculation with Temporary Variable refactoring
- Replace Magic Literals with Constants refactoring
- return values
- mocking / Mocking return values
- Rope
- about / The Rope refactoring library
- URL / The Rope refactoring library
- rule classes
- exploring / Exploring the Rule classes
S
- -s start_directory / Running the tests after the reorganization
- sequence of calls
- asserting / Pattern – asserting a sequence of calls
- Setup method / Setup and teardown
- setuptools
- about / Setuptools
- side effects
- mocking / Mocking side effects
- Single Responsibility Principle (SRP)
- about / Single Responsibility Principle
- skipping tests
- about / Skipping tests
- Sphinx
- about / Sphinx
- spies
- versus mocks / Mocks versus stubs versus fakes versus spies
- about / Pattern – spies
- sequence of calls, asserting / Pattern – asserting a sequence of calls
- open function, patching / Pattern – patching the open function
- mocking, with mutable args / Pattern – mocking with mutable args
- stock alert application, building with TDD
- about / Using TDD to build a stock alert application
- first test, writing / Writing our first test
- test output, analyzing / Analyzing the test output
- test errors, versus test failures / Test errors versus test failures
- test, making pass / Making the test pass
- test code, reorganizing / Reorganizing the test code
- tests, running after reorganization / Running the tests after the reorganization
- stubs
- versus mocks / Mocks versus stubs versus fakes versus spies
- subset of tests
- about / Pattern – running a subset of tests
- running / Pattern – running a subset of tests
- test loaders / Test loaders
- load_tests protocol, using / Using the load_tests protocol
- skipping tests / Skipping tests
- Sure
- system tests
T
- -t top_directory / Running the tests after the reorganization
- TDD
- prerequisites / Prerequisites
- about / Understanding test-driven development
- flowchart / Understanding test-driven development
- versus unit testing / TDD versus unit testing versus integration testing
- versus integration testing / TDD versus unit testing versus integration testing
- used, for building stock alert application / Using TDD to build a stock alert application
- TDD cycle
- executable requirements / Tests are executable requirements
- Arrange-Act-Assert / Arrange-Act-Assert
- tests, documenting / Documenting our tests
- exceptions, testing for / Testing for exceptions
- assert methods, exploring / Exploring assert methods
- specific asserts, versus generic asserts / Specific asserts versus generic asserts
- brittle tests / Brittle tests
- design, refactoring / Refactoring the design
- tests, refactoring / Refactoring tests
- rule classes, exploring / Exploring the Rule classes
- TDD process
- doctest, implementing / How do doctests fit into the TDD process?
- teardown method / Setup and teardown
- test brittleness
- example / Brittle tests
- test coverage
- measuring, with nose2 plugins / Measuring test coverage
- test double
- test failures
- about / Test failures
- debugging / Debugging test failures
- test loaders
- about / Test loaders
- test maintenance
- goals / Goals of test maintenance
- test results
- writing, to XML file / Writing test results to an XML file
- tests
- documenting / Documenting our tests
- refactoring / Refactoring tests
- importance / The importance of tests
- running, from command line / Running tests from the command line
- tests, writing closer to domain
- helper methods, writing / Writing helper methods
- better asserts, writing / Writing better asserts
- custom equality checkers, using / Using custom equality checkers
- matchers, using / Using matchers
- test suite
- tools, TDD
- tox
- about / tox
- Travis CI
- about / Travis CI
- Trial
U
- unittest.mock module
- unit testing
- unittest module
- about / Exploring assert methods
V
- vanilla unittests
- attributes, using / Attributes with vanilla unittests