[PYTHON] Try using pytest-Overview and Samples-

Note

I am a beginner in test technology. This post is also written by repeating trial and error. Therefore, (although I'm careful) what is written in this post is not always correct. Also, if you notice a mistake or make a new discovery, we will update it from time to time.

Introduction

In this article, I would like to touch on pytest, a testing tool for python. Specifically, I would like to introduce an overview (but copy and paste) of pytest and sample code. Other test tools for python include unittest, nose, and doctest. These will be introduced in another article.

environment

What is pytest

What is pytest? Python 2.6-3.4, PyPy and Jython-2.5.1 running on windows It is a test tool for. The difference from other test tools is

A big feature of this pytest is that you can easily parameterize the values used in the test methods. by [Algebra written in Python --pytest](http://blog.elliptium.net/2012/05/Python --- pytest)

Tomo

The only assertion to use is assert. You don't have to memorize the assert method endlessly. This simplicity is wonderful. by [How to get started with py.test](http://blog.craftgear.net/549a26cc5d7d17f472000002/title/py.test%E3%81%AE%E3%81%AF%E3%81%98%E3%82 % 81% E3% 81% 8B% E3% 81% 9F)

Tomo

It seems that you can run tests that integrate nose, unittest.py, and doctest.py, and you can run flexible tests with various options. Of course, you can also get coverage. by Python, Django area unit test situation (unittest / nose / django-nose)

Tomo

Assert is easy to use, has strong fixture and state management support, and works with a debugger. by Summary of unit test tools for Python

It's also said, but I'm a beginner, so I'm not sure. Will it become clear as you use it in various ways?

How to install

Anyway, I don't know anything unless I start, so let's install it for the time being. How to install

pip install -U pytest # or easy_install -U pytest by Installation and Getting Started is.

If you do not have pip installed, please refer to here.

Sample code

Recommended Posts

Try using pytest-Overview and Samples-
Try using Tkinter
Try using docker-py
Try using cookiecutter
Try using PDFMiner
Try using geopandas
Try using scipy
Try using pandas.DataFrame
Try using django-swiftbrowser
Try using matplotlib
Try using tf.metrics
Try using PyODE
Try using tensorflow ① Build python environment and introduce tensorflow
Try using ChatWork API and Qiita API in Python
Try using virtualenv (virtualenvwrapper)
[Azure] Try using Azure Functions
Try using virtualenv now
Try using W & B
Try using Django templates.html
Try using Python's feedparser.
Try using Python's Tkinter
Try using Tweepy [Python2.7]
Try using Pytorch's collate_fn
Try creating a compressed file using Python and zlib
Try to make it using GUI and PyQt in Python
Try using PythonTex with Texpad.
[Python] Try using Tkinter's canvas
Try using Jupyter's Docker image
Try function optimization using Hyperopt
Try using matplotlib with PyCharm
Try using Azure Logic Apps
Try using Kubernetes Client -Python-
[Kaggle] Try using xg boost
Try using the Twitter API
Try using AWS SageMaker Studio
Try tweeting automatically using Selenium.
Try using SQLAlchemy + MySQL (Part 1)
Try using the Twitter API
Try using SQLAlchemy + MySQL (Part 2)
Try MD simulation with ANN potential using aenet and ASE
Try using Django's template feature
Try using the PeeringDB 2.0 API
When using if and when using while
Try using Pelican's draft feature
Try using folium with anaconda
Try to recognize and distinguish Shanimas character images using YOLO v3
Try installing Git from source using Ansible's make and unarchive modules
Build and try an OpenCV & Python environment in minutes using Docker
Try using Janus gateway's Admin API
[Statistics] [R] Try using quantile regression.
Try using Spyder included in Anaconda
Try using design patterns (exporter edition)
Authentication using tweepy-User authentication and application authentication (Python)
Send messages and images using LineNotify
Try using Pillow on iPython (Part 2)
Precautions when using codecs and pandas
Notes on using post-receive and post-merge
Try using Pleasant's API (python / FastAPI)
Try using LevelDB in Python (plyvel)
Build TOPPERS / ASP3 and try it
Try using pynag to configure Nagios