TAILIEUCHUNG - Dive Into Python-Chapter 16. Functional Programming

Tham khảo tài liệu 'dive into python-chapter 16. functional programming', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 16. Functional Programming . Diving in In Chapter 13 Unit Testing you learned about the philosophy of unit testing. In Chapter 14 Test-First Programming you stepped through the implementation of basic unit tests in Python. In Chapter 15 Refactoring you saw how unit testing makes large-scale refactoring easier. This chapter will build on those sample programs but here we will focus more on advanced Python-specific techniques rather than on unit testing itself. The following is a complete Python program that acts as a cheap and simple regression testing framework. It takes unit tests that you ve written for individual modules collects them all into one big test suite and runs them all at once. I actually use this script as part of the build process for this book I have unit tests for several of the example programs not just the module featured in Chapter 13 Unit Testing and the first thing my automated build script does is run this program to make sure all my examples still work. If this regression test fails the build immediately stops. I don t want to release non-working examples any more than you want to download them and sit around scratching your head and yelling at your monitor and wondering why they don t work. Example . If you have not already done so you can download this and other examples used in this book. .Regression testing framework This module will search for scripts in the same directory named . Each such script should be a test suite that tests a module through PyUnit. As of Python PyUnit is included in the standard library as unittest . This script will aggregate all found test suites into one big test suite and run them all at once. import sys os re unittest def regressionTest path 0 files path test test .py files filter files filenameToModuleName lambda f f 0 moduleNames map .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.