چو ایران نباشد تن من مباد
Python Testing with pytest: Simple, Rapid, Effective, and Scalable

دانلود کتاب Python Testing with pytest: Simple, Rapid, Effective, and Scalable

83000 تومان موجود

کتاب تست پایتون با pytest: ساده، سریع، موثر و مقیاس پذیر نسخه زبان اصلی

دانلود کتاب تست پایتون با pytest: ساده، سریع، موثر و مقیاس پذیر بعد از پرداخت مقدور خواهد بود
توضیحات کتاب در بخش جزئیات آمده است و می توانید موارد را مشاهده فرمایید


این کتاب نسخه اصلی می باشد و به زبان فارسی نیست.


امتیاز شما به این کتاب (حداقل 1 و حداکثر 5):

امتیاز کاربران به این کتاب:        تعداد رای دهنده ها: 7


توضیحاتی در مورد کتاب Python Testing with pytest: Simple, Rapid, Effective, and Scalable

نام کتاب : Python Testing with pytest: Simple, Rapid, Effective, and Scalable
ویرایش : 2
عنوان ترجمه شده به فارسی : تست پایتون با pytest: ساده، سریع، موثر و مقیاس پذیر
سری :
نویسندگان :
ناشر : Pragmatic Bookshelf
سال نشر : 2022
تعداد صفحات : 0
ISBN (شابک) : 1680508601 , 9781680508604
زبان کتاب : English
فرمت کتاب : epub    درصورت درخواست کاربر به PDF تبدیل می شود
حجم کتاب : 5 مگابایت



بعد از تکمیل فرایند پرداخت لینک دانلود کتاب ارائه خواهد شد. درصورت ثبت نام و ورود به حساب کاربری خود قادر خواهید بود لیست کتاب های خریداری شده را مشاهده فرمایید.

توضیحاتی در مورد کتاب :




برنامه‌ها، بسته‌ها و کتابخانه‌های کوچک و بزرگ را با pytest، قدرتمندترین چارچوب آزمایشی پایتون، آزمایش کنید. pytest به شما کمک می کند تا تست ها را سریع بنویسید و آنها را خوانا و قابل نگهداری نگه دارید. در این نسخه کاملاً اصلاح‌شده، قدرت‌های فوق‌العاده pytest - ادعاهای ساده، فیکسچرها، پارامترسازی، نشانگرها و پلاگین‌ها - را در حین ایجاد تست‌های ساده و مجموعه‌های آزمایشی در برابر یک برنامه پایگاه داده کوچک بررسی کنید. با استفاده از یک مدل فیکسچر قوی و در عین حال ساده، نوشتن تست های کوچک با pytest به همان اندازه آسان است که مقیاس آن را تا تست های عملکردی پیچیده انجام دهید. این کتاب به شما نشان می دهد که چگونه.

pytest بدون شک بهترین انتخاب برای آزمایش پروژه های پایتون است. این یک چارچوب آزمایشی با امکانات کامل، انعطاف‌پذیر و قابل توسعه است. مدل فیکسچر pytest به شما امکان می دهد داده های تست و روش های راه اندازی را در چندین لایه آزمایش به اشتراک بگذارید. چارچوب pytest ویژگی‌های قدرتمندی مانند بازنویسی، پارامترسازی، نشانگرها، پلاگین‌ها، اجرای آزمایش موازی، و گزارش شکست تست واضح - بدون کد دیگ بخار را به شما می‌دهد.

با یک مرحله ساده. دستورالعمل های گام به گام و کد نمونه، این کتاب شما را به سرعت در این ابزار آسان برای یادگیری و در عین حال قدرتمند می رساند. تست های کوتاه و قابل نگهداری بنویسید که به زیبایی آنچه را که آزمایش می کنید بیان می کند. با توزیع تست‌ها در چندین پردازنده و اجرای آزمایش‌ها به صورت موازی، زمان‌های تست را افزایش دهید. از عبارات ادعای داخلی پایتون به جای توابع کمکی نامطلوب استفاده کنید تا تست های خود را خواناتر کنید. کد راه‌اندازی را به خارج از تست‌ها و به فیکسچرها منتقل کنید تا خرابی‌های راه‌اندازی را از شکست‌های تست جدا کنید. شرایط خطا و موارد گوشه را با آزمایش استثنای مورد انتظار آزمایش کنید و از یک تست برای اجرای بسیاری از موارد آزمایشی با آزمایش پارامتری شده استفاده کنید. pytest را با افزونه‌ها گسترش دهید، آن را به سیستم‌های یکپارچه‌سازی پیوسته متصل کنید، و از آن در کنار تست‌های tox، mock، coverage و حتی واحد تست موجود استفاده کنید.

تست‌های ساده و قابل نگهداری را به سرعت بنویسید. با pytest.

آنچه شما نیاز دارید:

نمونه‌های این کتاب با استفاده از Python 3.10 و pytest 7. pytest نوشته شده‌اند. 7 از پایتون 3.5 و بالاتر پشتیبانی می کند.


فهرست مطالب :


Cover
Table of Contents
Acknowledgments
Preface
Why pytest?
Learn pytest While Testing a Sample Application
How This Book Is Organized
What You Need to Know
Why a Second Edition?
Example Code and Online Resources
Part I—Primary Power
1. Getting Started with pytest
Installing pytest
Running pytest
Review
Exercises
What’s Next
2. Writing Test Functions
Installing the Sample Application
Writing Knowledge-Building Tests
Using assert Statements
Failing with pytest.fail() and Exceptions
Writing Assertion Helper Functions
Testing for Expected Exceptions
Structuring Test Functions
Grouping Tests with Classes
Running a Subset of Tests
Review
Exercises
What’s Next
3. pytest Fixtures
Getting Started with Fixtures
Using Fixtures for Setup and Teardown
Tracing Fixture Execution with –setup-show
Specifying Fixture Scope
Sharing Fixtures through conftest.py
Finding Where Fixtures Are Defined
Using Multiple Fixture Levels
Using Multiple Fixtures per Test or Fixture
Deciding Fixture Scope Dynamically
Using autouse for Fixtures That Always Get Used
Renaming Fixtures
Review
Exercises
What’s Next
4. Builtin Fixtures
Using tmp_path and tmp_path_factory
Using capsys
Using monkeypatch
Remaining Builtin Fixtures
Review
Exercises
What’s Next
5. Parametrization
Testing Without Parametrize
Parametrizing Functions
Parametrizing Fixtures
Parametrizing with pytest_generate_tests
Using Keywords to Select Test Cases
Review
Exercises
What’s Next
6. Markers
Using Builtin Markers
Skipping Tests with pytest.mark.skip
Skipping Tests Conditionally with pytest.mark.skipif
Expecting Tests to Fail with pytest.mark.xfail
Selecting Tests with Custom Markers
Marking Files, Classes, and Parameters
Using “and,” “or,” “not,” and Parentheses with Markers
Being Strict with Markers
Combining Markers with Fixtures
Listing Markers
Review
Exercises
What’s Next
Part II—Working with Projects
7. Strategy
Determining Test Scope
Considering Software Architecture
Evaluating the Features to Test
Creating Test Cases
Writing a Test Strategy
Review
Exercises
What’s Next
8. Configuration Files
Understanding pytest Configuration Files
Saving Settings and Flags in pytest.ini
Using tox.ini, pyproject.toml, or setup.cfg in place of pytest.ini
Determining a Root Directory and Config File
Sharing Local Fixtures and Hook Functions with conftest.py
Avoiding Test File Name Collision
Review
Exercises
What’s Next
9. Coverage
Using coverage.py with pytest-cov
Generating HTML Reports
Excluding Code from Coverage
Running Coverage on Tests
Running Coverage on a Directory
Running Coverage on a Single File
Review
Exercises
What’s Next
10. Mocking
Isolating the Command-Line Interface
Testing with Typer
Mocking an Attribute
Mocking a Class and Methods
Keeping Mock and Implementation in Sync with Autospec
Making Sure Functions Are Called Correctly
Creating Error Conditions
Testing at Multiple Layers to Avoid Mocking
Using Plugins to Assist Mocking
Review
Exercises
What’s Next
11. tox and Continuous Integration
What Is Continuous Integration?
Introducing tox
Setting Up tox
Running tox
Testing Multiple Python Versions
Running tox Environments in Parallel
Adding a Coverage Report to tox
Specifying a Minimum Coverage Level
Passing pytest Parameters Through tox
Running tox with GitHub Actions
Review
Exercises
What’s Next
12. Testing Scripts and Applications
Testing a Simple Python Script
Testing an Importable Python Script
Separating Code into src and tests Directories
Defining the Python Search Path
Testing requirements.txt-Based Applications
Review
Exercises
What’s Next
13. Debugging Test Failures
Adding a New Feature to the Cards Project
Installing Cards in Editable Mode
Debugging with pytest Flags
Re-Running Failed Tests
Debugging with pdb
Combining pdb and tox
Review
Exercises
What’s Next
Part III—Booster Rockets
14. Third-Party Plugins
Finding Plugins
Installing Plugins
Exploring the Diversity of pytest Plugins
Running Tests in Parallel
Randomizing Test Order
Review
Exercises
What’s Next
15. Building Plugins
Starting with a Cool Idea
Building a Local conftest Plugin
Creating an Installable Plugin
Testing Plugins with pytester
Testing Multiple Python and pytest Versions with tox
Publishing Plugins
Review
Exercises
What’s Next
16. Advanced Parametrization
Using Complex Values
Creating Custom Identifiers
Parametrizing with Dynamic Values
Using Multiple Parameters
Using Indirect Parametrization
Review
Exercises
What’s Next
A1. Virtual Environments
A2. pip
Index
– SYMBOLS –
– A –
– B –
– C –
– D –
– E –
– F –
– G –
– H –
– I –
– L –
– M –
– N –
– O –
– P –
– Q –
– R –
– S –
– T –
– U –
– V –
– W –
– X –
– Y –

توضیحاتی در مورد کتاب به زبان اصلی :


Test applications, packages, and libraries large and small with pytest, Python's most powerful testing framework. pytest helps you write tests quickly and keep them readable and maintainable. In this fully revised edition, explore pytest's superpowers - simple asserts, fixtures, parametrization, markers, and plugins - while creating simple tests and test suites against a small database application. 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. This book shows you how.

pytest is undeniably the best choice for testing Python projects. It's a full-featured, flexible, and extensible testing framework. pytest's fixture model allows you to share test data and setup procedures across multiple layers of tests. The pytest framework gives you powerful features such as assert rewriting, parametrization, markers, plugins, parallel test execution, and clear test failure reporting - 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 yet powerful tool. Write short, maintainable tests that elegantly express what you're testing. Speed up test times by distributing tests across multiple processors and running tests in parallel. Use Python's builtin assert statements instead of awkward assert helper functions to make your tests more readable. Move setup code out of tests and into fixtures to separate setup failures from 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, and even existing unittest tests.

Write simple, maintainable tests quickly with pytest.

What You Need:

The examples in this book were written using Python 3.10 and pytest 7. pytest 7 supports Python 3.5 and above.




پست ها تصادفی