چه کسانی این کتاب را می‌خوانند

دانشجوعلاقه‌مند یادگیری
کتابخوان حرفه‌ایلذت مطالعه
نویسندهالهام‌گیری

Python Testing with Pytest : Simple, Rapid, Effective, and Scalable

Brian Okken

قیمت نهایی

۴۰٬۰۰۰ تومان۴۹٬۰۰۰ تومان۱۸٪ تخفیف
  • تخفیف زمان‌دار−۹٬۰۰۰ تومان

۹٬۰۰۰ تومان صرفه‌جویی نسبت به قیمت اصلی

نسخه اصلی و اورجینال

بلافاصله پس از خرید، فایل کتاب روی دستگاه شما آمادهٔ دانلود است.

تحویل فوری
پرداخت امن
ضمانت فایل
پشتیبانی

مشخصات کتاب

نویسنده
Brian Okken
سال انتشار
۲۰۱۷
فرمت
PDF
زبان
انگلیسی
حجم فایل
۴٫۸ مگابایت

دربارهٔ کتاب

The pytest testing framework helps you write tests quickly and keep them readable and maintainable - with no boilerplate code. Using a robust yet simple fixture model, it's just as easy to write small tests with pytest as it is to scale up to complex functional testing for applications, packages, and libraries. This book shows you how. Do less work when testing your Python code, but be just as expressive, just as elegant, and just as readable. The pytest testing framework helps you write tests quickly and keep them readable and maintainable - with no boilerplate code. Using a robust yet simple fixture model, it's just as easy to write small tests with pytest as it is to scale up to complex functional testing for applications, packages, and libraries. This book shows you how. For Python-based projects, pytest is the undeniable choice to test your code if you're looking for a full-featured, API-independent, flexible, and extensible testing framework. With a full-bodied fixture model that is unmatched in any other tool, the pytest framework gives you powerful features such as assert rewriting and plug-in capability - with no boilerplate code. With simple step-by-step instructions and sample code, this book gets you up to speed quickly on this easy-to-learn and robust tool. Write short, maintainable tests that elegantly express what you're testing. Add powerful testing features and still speed up test times by distributing tests across multiple processors and running tests in parallel. Use the built-in assert statements to reduce false test failures by separating setup and test failures. Test error conditions and corner cases with expected exception testing, and use one test to run many test cases with parameterized testing. Extend pytest with plugins, connect it to continuous integration systems, and use it in tandem with tox, mock, coverage, unittest, and doctest. Write simple, maintainable tests that elegantly express what you're testing and why. What You Need: The examples in this book are written using Python 3.6 and pytest 3.0. However, pytest 3.0 supports Python 2.6, 2.7, and Python 3.3-3.6 Cover 1 Table of Contents 7 Acknowledgments 10 Preface 12 What Is pytest? 12 Learn pytest While Testing an Example Application 13 How This Book Is Organized 15 What You Need to Know 16 Example Code and Online Resources 17 1. Getting Started with pytest 18 Getting pytest 20 Running pytest 21 Running Only One Test 25 Using Options 26 Exercises 37 What’s Next 38 2. Writing Test Functions 39 Testing a Package 39 Using assert Statements 43 Expecting Exceptions 46 Marking Test Functions 47 Skipping Tests 50 Marking Tests as Expecting to Fail 53 Running a Subset of Tests 54 Parametrized Testing 58 Exercises 64 What’s Next 64 3. pytest Fixtures 65 Sharing Fixtures Through conftest.py 66 Using Fixtures for Setup and Teardown 67 Tracing Fixture Execution with –setup-show 68 Using Fixtures for Test Data 69 Using Multiple Fixtures 71 Specifying Fixture Scope 72 Specifying Fixtures with usefixtures 77 Using autouse for Fixtures That Always Get Used 77 Renaming Fixtures 79 Parametrizing Fixtures 80 Exercises 85 What’s Next 86 4. Builtin Fixtures 87 Using tmpdir and tmpdir_factory 87 Using pytestconfig 91 Using cache 93 Using capsys 100 Using monkeypatch 101 Using doctest_namespace 105 Using recwarn 108 Exercises 109 What’s Next 109 5. Plugins 110 Finding Plugins 111 Installing Plugins 111 Writing Your Own Plugins 113 Creating an Installable Plugin 117 Testing Plugins 120 Creating a Distribution 124 Exercises 125 What’s Next 126 6. Configuration 127 Understanding pytest Configuration Files 127 Changing the Default Command-Line Options 129 Registering Markers to Avoid Marker Typos 130 Requiring a Minimum pytest Version 131 Stopping pytest from Looking in the Wrong Places 131 Specifying Test Directory Locations 132 Changing Test Discovery Rules 133 Disallowing XPASS 134 Avoiding Filename Collisions 134 Exercises 136 What’s Next 137 7. Using pytest with Other Tools 138 pdb: Debugging Test Failures 138 Coverage.py: Determining How Much Code Is Tested 142 mock: Swapping Out Part of the System 146 tox: Testing Multiple Configurations 152 Jenkins CI: Automating Your Automated Tests 155 unittest: Running Legacy Tests with pytest 161 Exercises 166 What’s Next 167 A1. Virtual Environments 168 A2. pip 171 A3. Plugin Sampler Pack 174 Plugins That Change the Normal Test Run Flow 174 Plugins That Alter or Enhance Output 177 Plugins for Static Analysis 182 Plugins for Web Development 183 A4. Packaging and Distributing Python Projects 185 Creating an Installable Module 185 Creating an Installable Package 186 Creating a Source Distribution and Wheel 188 Creating a PyPI-Installable Package 192 A5. xUnit Fixtures 193 Syntax of xUnit Fixtures 193 Mixing pytest Fixtures and xUnit Fixtures 195 Limitations of xUnit Fixtures 197 Index 198 – SYMBOLS – 198 – A – 198 – B – 198 – C – 198 – D – 199 – E – 199 – F – 200 – G – 201 – H – 201 – I – 201 – J – 201 – K – 201 – L – 201 – M – 201 – N – 202 – O – 202 – P – 202 – Q – 203 – R – 203 – S – 203 – T – 204 – U – 205 – V – 205 – W – 206 – X – 206 – Y – 206 – Z – 206

قیمت نهایی

۴۰٬۰۰۰ تومان