{"id":267043,"date":"2015-10-29T12:17:03","date_gmt":"2015-10-29T09:17:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=267043"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=267043","title":{"rendered":"PyTest"},"content":{"rendered":"<br \/>\n<h4>\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h4>\n<p>  \u041f\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043f\u0440\u0438\u0437\u0432\u0430\u043d\u0438\u044e \u044f SQL-\u0449\u0438\u043a. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0443\u0434\u044c\u0431\u0430 \u0437\u0430\u043d\u0435\u0441\u043b\u0430 \u043c\u0435\u043d\u044f \u043d\u0430 BigData \u0438 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043d\u0435\u0441\u043b\u0430 \u043a\u0440\u0438\u0432\u0430\u044f \u2014 \u044f \u043e\u0441\u0432\u043e\u0438\u043b \u0438 Java, \u0438 Python, \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 Scala \u0441\u0442\u043e\u0438\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435). \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043a\u0443\u0441\u043a\u043e\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u0441\u0442\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u043d\u0430 Python. \u0420\u0435\u0431\u044f\u0442\u0430 \u0438\u0437 QA \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b\u0438 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 PyTest, \u043d\u043e \u0434\u0430\u0436\u0435 \u043e\u043d\u0438 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0438\u043b\u0438\u0441\u044c \u0442\u043e\u043b\u043a\u043e\u043c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0447\u0435\u043c \u044d\u0442\u043e\u0442 \u0437\u0432\u0435\u0440\u044c \u0445\u043e\u0440\u043e\u0448. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0432\u043e\u043f\u0440\u043e\u0441\u0443 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043c\u043d\u043e\u0433\u043e: <a href=\"http:\/\/habrahabr.ru\/company\/yandex\/blog\/242795\/\">\u043a\u0430\u043a \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0432 Yandex<\/a> \u0434\u0430 \u0438 \u0432\u0441\u0435 \u043f\u043e-\u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432 \u044d\u0442\u043e\u043c \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0434\u043b\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0442\u0435\u0437\u0435. \u041d\u0435 \u0433\u043e\u0432\u043e\u0440\u044f \u0443\u0436\u0435 \u043e\u0431 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u2014 \u043e\u043d\u0430 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u043b\u0430 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u0441\u043c\u044b\u0441\u043b \u043b\u0438\u0448\u044c \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u0441 \u0441\u0430\u043c\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c. \u041d\u0435 \u0441\u043f\u043e\u0440\u044e, \u0442\u0430\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0432\u0435\u0449\u0438, \u043d\u043e, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u0442\u0430.<\/p>\n<h4>\u042e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 Python<\/h4>\n<p>  \u0427\u0442\u043e \u044d\u0442\u043e \u0438 \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043c\u044b\u0441\u043b\u0430 \u043d\u0435 \u0432\u0438\u0436\u0443 \u2014 \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u044f \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0437\u043d\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435. \u041f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0434\u043b\u044f Python <a href=\"http:\/\/habrahabr.ru\/post\/121162\">\u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0430 \u0425\u0430\u0431\u0440\u0435<\/a>.<\/p>\n<h4>\u0412\u0432\u043e\u0434\u043d\u0430\u044f \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0437\u043d\u0430\u043d\u0438\u044f\u043c<\/h4>\n<p>  \u041d\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u043d\u0430\u043d\u0438\u044f Python \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u044b \u2014 \u044f \u043f\u0438\u0441\u0430\u043b \u043a\u043e\u0435-\u043a\u0430\u043a\u0438\u0435 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0438 \u0437\u043d\u0430\u043b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0432\u0435\u0449\u0438. \u041d\u043e \u043f\u0440\u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u0441 PyTest \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0431\u0430\u0433\u0430\u0436 \u0437\u043d\u0430\u043d\u0438\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/141411\/\">\u0442\u0443\u0442<\/a> \u0438 <a href=\"http:\/\/habrahabr.ru\/post\/141501\/\">\u0442\u0443\u0442<\/a> \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 <a href=\"http:\/\/habrahabr.ru\/post\/132554\/\">yield<\/a>.<\/p>\n<h4>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 PyTest<\/h4>\n<p>  1) \u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 API (no boilerplate). \u041a\u0430\u043a \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u0442\u043e\u043c \u0436\u0435 unittest:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">import unittest  class TestUtilDate(unittest.TestCase):     def setUp(self):         #init_something()         pass              def tearDown(self):         #teardown_something()         pass              def test_upper(self):         self.assertEqual('foo'.upper(), 'FOO')              def test_isupper(self):         self.assertTrue('FOO'.isupper())              def test_failed_upper(self):         self.assertEqual('foo'.upper(), 'FOo')          if __name__ == '__main__':     suite = unittest.TestLoader().loadTestsFromTestCase(TestUtilDate)     unittest.TextTestRunner(verbosity=2).run(suite) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0432 PyTest:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">import pytest  def setup_module(module):     #init_something()     pass  def teardown_module(module):     #teardown_something()     pass  def test_upper():     assert 'foo'.upper() == 'FOO'      def test_isupper():     assert 'FOO'.isupper()      def test_failed_upper():     assert 'foo'.upper() == 'FOo' <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  2) \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u043e\u0442\u0447\u0435\u0442. \u0412 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0432 JUnitXML (\u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0441 Jenkins). \u0421\u0430\u043c \u0432\u0438\u0434 \u043e\u0442\u0447\u0435\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0446\u0432\u0435\u0442\u0430) \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438 (\u043e \u043d\u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e). \u041d\u0443 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0446\u0432\u0435\u0442\u043d\u043e\u0439 \u043e\u0442\u0447\u0435\u0442 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u2014 \u043a\u0440\u0430\u0441\u043d\u044b\u0435 FAILED \u0432\u0438\u0434\u043d\u044b \u0441\u0440\u0430\u0437\u0443.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/7e1\/4f3\/b8b\/7e14f3b8b89a4aac849e98432b098e98.jpg\" alt=\"image\"\/><\/p>\n<p>  3) \u0423\u0434\u043e\u0431\u043d\u044b\u0439 asset (\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0438\u0437 Python). \u041d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0433\u043e\u043b\u043e\u0432\u0435 \u0432\u0441\u044e \u043a\u0443\u0447\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 assert&#8217;\u043e\u0432.<\/p>\n<p>  4) \u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b \u0432\u0441\u0435\u0445 \u0443\u0440\u043e\u0432\u043d\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>  5) \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0444\u0438\u043a\u0441\u0442\u0443\u0440 (\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b, \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043e\u0431\u044a\u0435\u043a\u0442 request, \u0430\u0432\u0442\u043e\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b)<\/p>\n<p>  6) \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432, \u0442\u043e \u0435\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0442\u0435\u0441\u0442\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043d\u0430\u0431\u043e\u0440\u0430\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0412\u043e\u043e\u0431\u0449\u0435 \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043f\u0443\u043d\u043a\u0442\u0443 5 \u00ab\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u00bb, \u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0440\u043e\u0448\u0430, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u043e\u0439\u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430.<\/p>\n<p>  7) \u041c\u0435\u0442\u043a\u0438 (marks), \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0442\u0435\u0441\u0442, \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u0442\u0435\u0441\u0442, \u043a\u0430\u043a \u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 (\u0438 \u044d\u0442\u043e \u0435\u0433\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435) \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0442\u0435\u0441\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0433\u043e \u043f\u043e \u0438\u043c\u0435\u043d\u0438.<\/p>\n<p>  8) \u041f\u043b\u0430\u0433\u0438\u043d\u044b. \u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  9) \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 unittest \u0438 nose, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0441 \u043d\u0438\u043c\u0438.<\/p>\n<p>  \u041f\u0440\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438, \u043f\u0443\u0441\u0442\u044c \u0438\u0445 \u0438 \u043d\u0435 \u043c\u043d\u043e\u0433\u043e, \u043c\u043e\u0433\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  1) \u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438: \u0414\u043b\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u0435\u0441\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c. \u041d\u043e \u043b\u043e\u0433\u0438\u043a\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f testcase, \u043a\u043e\u0433\u0434\u0430 \u0442\u0430 \u0436\u0435 \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e testcase&#8217;\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u043e\u0437\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438 \u043e\u0448\u0438\u0431\u043e\u043a). \u042d\u0442\u043e \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u043a\u043e\u043c\u043f\u0435\u043d\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u043c (\u043f\u043b\u0430\u0433\u0438\u043d\u043e\u043c) pytest-describe, \u043d\u043e \u0442\u0430\u043c \u0432\u0441\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b (scope = \u201cdescribe\u201d). \u0421 \u044d\u0442\u0438\u043c \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0436\u0438\u0442\u044c, \u043d\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f PyTest \u2014 \u00ab\u0432\u0441\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430\u00bb.<\/p>\n<p>  2) \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u043e\u0434\u0443\u043b\u044f, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435. \u0412\u0441\u0435-\u0442\u0430\u043a\u0438 unittest \u0438 doctest \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 Python \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u043b\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>  3) \u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f PyTest \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u043d\u0430\u043d\u0438\u0439 Python, \u0447\u0435\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0436\u0435 unittest (\u0441\u043c. \u00ab\u0412\u0432\u043e\u0434\u043d\u0430\u044f \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u00bb).<\/p>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u044f \u0438 \u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0417\u0430\u043f\u0443\u0441\u043a \u0442\u0435\u0441\u0442\u043e\u0432<\/h4>\n<p>  \u0414\u043b\u044f unittest \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 main. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0443\u0441\u043a \u0438\u043c\u0435\u0435\u0442 \u0432\u0438\u0434 \u00abpython unittest_example.py\u00bb. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0438\u0445 \u0432 TestSuit \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e. PyTest \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b \u0441\u0430\u043c \u043f\u043e \u0438\u043c\u0435\u043d\u0438 test_* (Test_* \u0434\u043b\u044f \u0438\u043c\u0435\u043d\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432) \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u0430\u043f\u043a\u0435 (\u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u043e\u0431\u0445\u043e\u0434\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u043f\u043a\u0438) \u0438\u043b\u0438 \u0436\u0435 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434 \u00abpy.test -v pytest_example.py\u00bb<\/p>\n<h4>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b<\/h4>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0430\u043c\u0438 \u044f \u043d\u0430\u0437\u044b\u0432\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430. PyTest, \u043a\u0430\u043a \u0438 unittest, \u0438\u043c\u0435\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0444\u0438\u043a\u0441\u0442\u0443\u0440 \u0432\u0441\u0435\u0445 \u0443\u0440\u043e\u0432\u043d\u0435\u0439:<\/p>\n<pre><code class=\"python\">import pytest  def setup():     print (&quot;basic setup into module&quot;)   def teardown():     print (&quot;basic teardown into module&quot;)  def setup_module(module):     print (&quot;module setup&quot;)   def teardown_module(module):     print (&quot;module teardown&quot;)   def setup_function(function):     print (&quot;function setup&quot;)   def teardown_function(function):     print (&quot;function teardown&quot;)   def test_numbers_3_4():     print &quot;test 3*4&quot;     assert 3*4 == 12    def test_strings_a_3():     print &quot;test a*3&quot;     assert 'a'*3 == 'aaa'     class TestUM:     def setup(self):         print (&quot;basic setup into class&quot;)       def teardown(self):         print (&quot;basic teardown into class&quot;)       def setup_class(cls):         print (&quot;class setup&quot;)       def teardown_class(cls):         print (&quot;class teardown&quot;)       def setup_method(self, method):         print (&quot;method setup&quot;)       def teardown_method(self, method):         print (&quot;method teardown&quot;)       def test_numbers_5_6(self):         print &quot;test 5*6&quot;         assert 5*6 == 30        def test_strings_b_2(self):         print &quot;test b*2&quot;         assert 'b'*2 == 'bb' <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0435\u0441\u044c \u0432\u044b\u0432\u043e\u0434 \u0432\u044b\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 print, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442 \u0441 \u0444\u043b\u0430\u0433\u043e\u043c -s:<\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s basic_fixtures.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 rootdir: tmp\/, inifile: collected 4 items  basic_fixtures.py module setup function setup basic setup into module test 3*4 .basic teardown into module function teardown function setup basic setup into module test a*3 .basic teardown into module function teardown class setup method setup basic setup into class test 5*6 .basic teardown into class method teardown method setup basic setup into class test b*2 .basic teardown into class method teardown class teardown module teardown ========================== 4 passed in 0.03 seconds  <\/code><\/pre>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043b\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c\u043e\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0444\u0438\u043a\u0441\u0442\u0443\u0440 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, setup_function \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0430 setup_module \u2013 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f). \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\/\u043c\u0435\u0442\u043e\u0434 (\u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0430 setup \u0438 teardown).<\/p>\n<h4>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0435 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b<\/h4>\n<p>  \u0412\u043e\u043f\u0440\u043e\u0441 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435, \u0430 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u0435\u0442? \u0420\u0430\u0437\u043d\u043e\u0441\u0438\u0442\u044c \u043f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u043c\u043e\u0434\u0443\u043b\u044f\u043c \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c? \u041d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u041d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0435 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b PyTest.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0439 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b \u0432 PyTest \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e:<\/p>\n<p>  1) \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c pytest<br \/>  2) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440  @pytest.fixture(), \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u043e\u0439<br \/>  3) \u0437\u0430\u0434\u0430\u0442\u044c \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b (scope). \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u201cfunction\u201d, \u201ccls\u201d, \u201cmodule\u201d, \u201csession\u201d. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e = \u201cfunction\u201d.<br \/>  4) \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0432\u044b\u0437\u043e\u0432 teardown \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b, \u0442\u043e \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 (\u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 addfinalizer \u043e\u0431\u044a\u0435\u043a\u0442\u0430 request \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0432 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0443 \u0438\u043b\u0438 \u0436\u0435 \u0447\u0435\u0440\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 yield)<br \/>  5) \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043c\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<pre><code class=\"python\">import pytest   @pytest.fixture() def resource_setup(request):     print(&quot;resource_setup&quot;)     def resource_teardown():         print(&quot;resource_teardown&quot;)     request.addfinalizer(resource_teardown)      def test_1_that_needs_resource(resource_setup):     print(&quot;test_1_that_needs_resource&quot;)   def test_2_that_does_not():     print(&quot;test_2_that_does_not&quot;)   def test_3_that_does_again(resource_setup):     print(&quot;test_3_that_does_again&quot;) <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s extended_fixture.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 rootdir: tmp\/, inifile: collected 3 items  extended_fixture.py resource_setup test_1_that_needs_resource .resource_teardown test_2_that_does_not .resource_setup test_3_that_does_again .resource_teardown ========================== 3 passed in 0.01 seconds  <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0412\u044b\u0437\u043e\u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0445 \u0444\u0438\u043a\u0441\u0442\u0443\u0440<\/h4>\n<p>  \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0435 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0449\u0435 \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<\/p>\n<p>  1) \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u0430 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c  @pytest.mark.usefixtures()<br \/>  2) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430 autouse \u0434\u043b\u044f \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0438\u0442\u043e\u0433\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432.<br \/>  3) \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u0441\u043f\u043e\u0441\u043e\u0431 \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0442\u0435\u0441\u0442\u0430<\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"python\">import pytest   @pytest.fixture() def resource_setup(request):     print(&quot;resource_setup&quot;)     def resource_teardown():         print(&quot;resource_teardown&quot;)     request.addfinalizer(resource_teardown)      @pytest.fixture(scope=&quot;function&quot;, autouse=True) def another_resource_setup_with_autouse(request):     print(&quot;another_resource_setup_with_autouse&quot;)     def resource_teardown():         print(&quot;another_resource_teardown_with_autouse&quot;)     request.addfinalizer(resource_teardown)      def test_1_that_needs_resource(resource_setup):     print(&quot;test_1_that_needs_resource&quot;)   def test_2_that_does_not():     print(&quot;test_2_that_does_not&quot;)   @pytest.mark.usefixtures(&quot;resource_setup&quot;) def test_3_that_does_again():     print(&quot;test_3_that_does_again&quot;) <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s call_extended_fixtures.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 rootdir: tmp\/, inifile: collected 3 items  call_extended_fixtures.py another_resource_setup_with_autouse resource_setup test_1_that_needs_resource .resource_teardown another_resource_teardown_with_autouse another_resource_setup_with_autouse test_2_that_does_not .another_resource_teardown_with_autouse another_resource_setup_with_autouse resource_setup test_3_that_does_again .resource_teardown another_resource_teardown_with_autouse ========================== 3 passed in 0.01 seconds <\/code><\/pre>\n<p>  <\/p>\n<h4>teardown \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0439 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b<\/h4>\n<p>  \u041a\u0430\u043a \u0431\u044b\u043b\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0432\u044b\u0437\u043e\u0432 teardown \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0439 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<\/p>\n<p>  1) \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0443 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 (\u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 addfinalizer \u043e\u0431\u044a\u0435\u043a\u0442\u0430 request \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0432 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0443<br \/>  2) \u0447\u0435\u0440\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 yield (\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 PyTest \u0432\u0435\u0440\u0441\u0438\u0438 2.4)<\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0439 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b. \u0422\u0435\u043f\u0435\u0440\u044c \u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0442\u0443 \u0436\u0435 \u0441\u0430\u043c\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 yield. \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f yield \u043f\u0440\u0438 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u0430\u043a \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440  @pytest.yield_fixture(), \u0430 \u043d\u0435  @pytest.fixture():<\/p>\n<pre><code class=\"python\">import pytest   @pytest.yield_fixture() def resource_setup():     print(&quot;resource_setup&quot;)     yield     print(&quot;resource_teardown&quot;)      def test_1_that_needs_resource(resource_setup):     print(&quot;test_1_that_needs_resource&quot;)   def test_2_that_does_not():     print(&quot;test_2_that_does_not&quot;)   def test_3_that_does_again(resource_setup):     print(&quot;test_3_that_does_again&quot;) <\/code><\/pre>\n<p>  \u0412\u044b\u0432\u043e\u0434 \u043d\u0435 \u0431\u0443\u0434\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0442\u0435\u043a\u0441\u0442 \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043e\u043d \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0441 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c.<\/p>\n<h4>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041a\u0430\u043a \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0430 \u0432 PyTest \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0432 \u0442\u0435\u0441\u0442 \u0447\u0435\u0440\u0435\u0437 return. \u0411\u0443\u0434\u044c \u0442\u043e \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0442\u0430\u043a \u0438 \u043e\u0431\u044a\u0435\u043a\u0442 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0430\u0439\u043b).<\/p>\n<pre><code class=\"python\">import pytest   @pytest.fixture(scope=&quot;module&quot;) def resource_setup(request):     print(&quot;\\nconnect to db&quot;)     db = {&quot;Red&quot;:1,&quot;Blue&quot;:2,&quot;Green&quot;:3}     def resource_teardown():         print(&quot;\\ndisconnect&quot;)     request.addfinalizer(resource_teardown)     return db      def test_db(resource_setup):     for k in resource_setup.keys():         print &quot;color {0} has id {1}&quot;.format(k, resource_setup[k])   def test_red(resource_setup):     assert resource_setup[&quot;Red&quot;] == 1   def test_blue(resource_setup):     assert resource_setup[&quot;Blue&quot;] != 1 <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -v -s return_value.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp\/, inifile: collected 3 items  return_value.py::test_db connect to db color Blue has id 2 color Green has id 3 color Red has id 1 PASSED return_value.py::test_red PASSED return_value.py::test_blue PASSED disconnect ========================== 3 passed in 0.02 seconds <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b (scope)<\/h4>\n<p>  \u0423\u0440\u043e\u0432\u0435\u043d\u044c \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u201cfunction\u201d, \u201ccls\u201d, \u201cmodule\u201d, \u201csession\u201d. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e = \u201cfunction\u201d.\\<\/p>\n<p>  function \u2013 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430<br \/>  cls \u2013 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430<br \/>  module \u2013 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f<br \/>  session \u2013 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 (\u0442\u043e \u0435\u0441\u0442\u044c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0434\u0438\u043d \u0440\u0430\u0437)<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c scope \u043d\u0430 function \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code class=\"python\">import pytest   @pytest.fixture(scope=&quot;function&quot;) def resource_setup(request):     print(&quot;\\nconnect to db&quot;)     db = {&quot;Red&quot;:1,&quot;Blue&quot;:2,&quot;Green&quot;:3}     def resource_teardown():         print(&quot;\\ndisconnect&quot;)     request.addfinalizer(resource_teardown)     return db      def test_db(resource_setup):     for k in resource_setup.keys():         print &quot;color {0} has id {1}&quot;.format(k, resource_setup[k])   def test_red(resource_setup):     assert resource_setup[&quot;Red&quot;] == 1   def test_blue(resource_setup):     assert resource_setup[&quot;Blue&quot;] != 1 <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -v -s scope.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp\/, inifile: collected 3 items  scope.py::test_db connect to db color Blue has id 2 color Green has id 3 color Red has id 1 PASSED disconnect  scope.py::test_red connect to db PASSED disconnect  scope.py::test_blue connect to db PASSED disconnect ========================== 3 passed in 0.02 seconds <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0435 conftest.py, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f PyTest. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c (\u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0443 \u0441 \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u00ab\u0441\u0435\u0441\u0441\u0438\u044f\u00bb).<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0430\u043f\u043a\u0443 session scope \u0441 \u0444\u0430\u0439\u043b\u043e\u043c conftest.py \u0438 \u0434\u0432\u0443\u043c\u044f \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 (\u043d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0447\u0442\u043e\u0431\u044b PyTest \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043c\u043e\u0434\u0443\u043b\u0438 \u0438\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 test_. \u0425\u043e\u0442\u044f \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c.):<\/p>\n<p>  <i>conftest.py:<\/i><\/p>\n<pre><code class=\"python\">import pytest  @pytest.fixture(scope=&quot;session&quot;, autouse=True) def auto_session_resource(request):     &quot;&quot;&quot; Auto session resource fixture     &quot;&quot;&quot;     print(&quot;auto_session_resource_setup&quot;)     def auto_session_resource_teardown():         print(&quot;auto_session_resource_teardown&quot;)     request.addfinalizer(auto_session_resource_teardown)      @pytest.fixture(scope=&quot;session&quot;) def manually_session_resource(request):     &quot;&quot;&quot; Manual set session resource fixture     &quot;&quot;&quot;     print(&quot;manually_session_resource_setup&quot;)     def manually_session_resource_teardown():         print(&quot;manually_session_resource_teardown&quot;)     request.addfinalizer(manually_session_resource_teardown)      @pytest.fixture(scope=&quot;function&quot;) def function_resource(request):     &quot;&quot;&quot; Function resource fixture     &quot;&quot;&quot;     print(&quot;function_resource_setup&quot;)     def function_resource_teardown():         print(&quot;function_resource_teardown&quot;)     request.addfinalizer(function_resource_teardown) <\/code><\/pre>\n<p>  <i>test_session_scope1.py<\/i><\/p>\n<pre><code class=\"python\">import pytest   def test_1_that_does_not_need_session_resource():     print(&quot;test_1_that_does_not_need_session_resource&quot;)   def test_2_that_does(manually_session_resource):     print(&quot;test_2_that_does&quot;) <\/code><\/pre>\n<p>  <i>test_session_scope2.py<\/i><\/p>\n<pre><code class=\"python\">import pytest   def test_3_that_uses_all_fixtures(manually_session_resource, function_resource):     print(&quot;test_2_that_does_not&quot;) <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"diff\">tmp\\session scope&gt;py.test -s -v ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\pro ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp\\session scope, inifile: collected 3 items  test_session_scope1.py::test_1_that_does_not_need_session_resource auto_session resource_setup test_1_that_does_not_need_session_resource PASSED test_session_scope1.py::test_2_that_does manually_session_resource_setup test_2_that_does PASSED test_session_scope2.py::test_3_that_uses_all_fixtures function_resource_setup test_2_that_does_not PASSEDfunction_resource_teardown manually_session_resource_teardown auto_session_resource_teardown ========================== 3 passed in 0.02 seconds <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0442\u043e, \u0447\u0442\u043e PyTest \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 &#8212;fixtures, \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0444\u0438\u043a\u0441\u0442\u0440\u0443\u0440\u044b, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 conftest.py (\u0438\u043c\u0435\u043b\u0438 docstring).<\/p>\n<pre><code class=\"diff\">tmp\\session scope&gt;py.test --fixtures ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 rootdir: tmp\\session scope, inifile: collected 3 items cache     Return a cache object that can persist state between testing sessions. \u2026.....     path object.  ----------------------- fixtures defined from conftest ------------------------ manually_session_resource     Manual set session resource fixture function_resource     Function resource fixture auto_session_resource     Auto session resource fixture ==============================  in 0.07 seconds  <\/code><\/pre>\n<p>  <\/p>\n<h4>\u041e\u0431\u044a\u0435\u043a\u0442 request<\/h4>\n<p>  \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0439 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0432 \u043d\u0435\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 request. \u042d\u0442\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0447\u0442\u043e\u0431\u044b \u0447\u0435\u0440\u0435\u0437 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 addfinalizer \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (\u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432 <a href=\"http:\/\/pytest.org\/latest\/builtin.html#fixtures-and-requests\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c API<\/a>).<\/p>\n<pre><code class=\"python\">import pytest   @pytest.fixture(scope=&quot;function&quot;) def resource_setup(request):     print request.fixturename     print request.scope     print request.function.__name__     print request.cls     print request.module.__name__     print request.fspath      def test_1(resource_setup):     assert True   class TestClass():     def test_2(self, resource_setup):         assert True <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -v -s request_object.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp\/, inifile: collected 2 items  request_object.py::test_1 resource_setup function test_1 None 08 tmp\\request_object.py PASSED request_object.py::TestClass::test_2 resource_setup function test_2 08.TestClass 08 tmp\\request_object.py PASSED ========================== 2 passed in 0.04 seconds  <\/code><\/pre>\n<p>  <\/p>\n<h4>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/h4>\n<p>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u2014 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0442\u0435\u0441\u0442 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u043a \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u043a \u0441\u0442\u0440\u043e\u043a\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0434\u043b\u0438\u043d\u043d\u0435\u0435 5 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0432\u043e\u0441\u043a\u043b\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u043d\u0430\u043a \u2014 \u043c\u0435\u043d\u0435\u0435 5 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438 \u0442\u043e\u0447\u043a\u0443, \u0435\u0441\u043b\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u0440\u043e\u0432\u043d\u043e 5 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0440\u0438 \u0442\u0435\u0441\u0442\u0430, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0434\u0438\u043d, \u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438.<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<\/p>\n<p>  1) \u0427\u0435\u0440\u0435\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 params \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<br \/>  \u0422\u043e \u0435\u0441\u0442\u044c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0430 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0431\u0435\u0440\u0442\u043a\u0443, \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0443\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u0410 \u0432 \u0441\u0430\u043c \u0442\u0435\u0441\u0442 \u043e\u043d\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 param \u043e\u0431\u044a\u0435\u043a\u0442\u0430 request, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435.<br \/>  2) \u0427\u0435\u0440\u0435\u0437 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 (\u043c\u0435\u0442\u043a\u0443)  @pytest.mark.parametrize, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u0418\u0442\u0430\u043a \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431.<\/p>\n<pre><code class=\"python\">import pytest   def strange_string_func(str):     if len(str) &gt; 5:         return str + &quot;?&quot;     elif len(str) &lt; 5:         return str + &quot;!&quot;     else:         return str + &quot;.&quot;   @pytest.fixture(scope=&quot;function&quot;, params=[ (&quot;abcdefg&quot;, &quot;abcdefg?&quot;), (&quot;abc&quot;, &quot;abc!&quot;), (&quot;abcde&quot;, &quot;abcde.&quot;) ]) def param_test(request):     return request.param      def test_strange_string_func(param_test):     (input, expected_output) = param_test     result = strange_string_func(input)     print &quot;input: {0}, output: {1}, expected: {2}&quot;.format(input, result, expected_output)     assert result == expected_output <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v parametrizing_base.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp\/, inifile: collected 3 items  parametrizing_base.py::test_strange_string_func[param_test0] input: abcdefg, output: abcdefg?, e xpected: abcdefg? PASSED parametrizing_base.py::test_strange_string_func[param_test1] input: abc, output: abc!, expected:  abc! PASSED parametrizing_base.py::test_strange_string_func[param_test2] input: abcde, output: abcde., expec ted: abcde. PASSED  ========================== 3 passed in 0.03 seconds  <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0440\u043e\u043c\u0435 \u043e\u0434\u043d\u043e\u0439 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0439 \u0434\u0435\u0442\u0430\u043b\u0438 \u2014 \u043f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u0442\u0435\u0441\u0442\u0430 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0437\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0431\u044b\u043b \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u0432 \u0442\u0435\u0441\u0442. \u0418 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0440\u0443\u0447\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 ids \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b. \u041e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0438\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043c\u0435\u043d \u0442\u0435\u0441\u0442\u043e\u0432 (\u0435\u0433\u043e \u0434\u043b\u0438\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043e\u043d\u044b\u0445), \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">import pytest   def strange_string_func(str):     if len(str) &gt; 5:         return str + &quot;?&quot;     elif len(str) &lt; 5:         return str + &quot;!&quot;     else:         return str + &quot;.&quot;   @pytest.fixture(scope=&quot;function&quot;, params=[ (&quot;abcdefg&quot;, &quot;abcdefg?&quot;), (&quot;abc&quot;, &quot;abc!&quot;), (&quot;abcde&quot;, &quot;abcde.&quot;)], ids=[&quot;len&gt;5&quot;,&quot;len&lt;5&quot;,&quot;len==5&quot;] ) def param_test(request):     return request.param      def test_strange_string_func(param_test):     (input, expected_output) = param_test     result = strange_string_func(input)     print &quot;input: {0}, output: {1}, expected: {2}&quot;.format(input, result, expected_output)     assert result == expected_output      def idfn(val):     return &quot;params: {0}&quot;.format(str(val))      @pytest.fixture(scope=&quot;function&quot;, params=[ (&quot;abcdefg&quot;, &quot;abcdefg?&quot;), (&quot;abc&quot;, &quot;abc!&quot;), (&quot;abcde&quot;, &quot;abcde.&quot;)], ids=idfn ) def param_test_idfn(request):     return request.param      def test_strange_string_func_with_ifdn(param_test_idfn):     (input, expected_output) = param_test     result = strange_string_func(input)     print &quot;input: {0}, output: {1}, expected: {2}&quot;.format(input, result, expected_output)     assert result == expected_output <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v parametrizing_named.py --collect-only ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp\/, inifile: collected 6 items &lt;Module 'parametrizing_named.py'&gt;   &lt;Function 'test_strange_string_func[len&gt;5]'&gt;   &lt;Function 'test_strange_string_func[len&lt;5]'&gt;   &lt;Function 'test_strange_string_func[len==5]'&gt;   &lt;Function &quot;test_strange_string_func_with_ifdn[params: ('abcdefg', 'abcdefg?')] &quot;&gt;   &lt;Function &quot;test_strange_string_func_with_ifdn[params: ('abc', 'abc!')]&quot;&gt;   &lt;Function &quot;test_strange_string_func_with_ifdn[params: ('abcde', 'abcde.')]&quot;&gt; ==============================  in 0.03 seconds <\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b PyTest \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u2014collect-only, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b, \u043f\u043e\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u0431\u0435\u0437 \u0438\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u0430.<\/p>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u043c\u0435\u0435\u0442 \u043e\u0434\u043d\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e: \u0435\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u043a \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u0442\u0435\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c\u0438 \u043d\u0430\u0431\u043e\u0440\u0430\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 (\u0442\u043e \u0435\u0441\u0442\u044c \u0434\u0435\u043a\u0430\u0440\u0442\u043e\u0432\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432).<\/p>\n<pre><code class=\"python\">import pytest   @pytest.mark.parametrize(&quot;x&quot;, [1,2]) @pytest.mark.parametrize(&quot;y&quot;, [10,11]) def test_cross_params(x, y):     print &quot;x: {0}, y: {1}&quot;.format(x, y)     assert True <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v parametrizing_combinations.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp\/, inifile: collected 4 items  parametrizing_combinations.py::test_cross_params[10-1] x: 1, y: 10 PASSED parametrizing_combinations.py::test_cross_params[10-2] x: 2, y: 10 PASSED parametrizing_combinations.py::test_cross_params[11-1] x: 1, y: 11 PASSED parametrizing_combinations.py::test_cross_params[11-2] x: 2, y: 11 PASSED ========================== 4 passed in 0.02 seconds  <\/code><\/pre>\n<p>  \u0412 \u043c\u0435\u0442\u043a\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 ids, \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0437\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u0432\u044b\u0432\u043e\u0434\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u0441\u043f\u043e\u0441\u043e\u0431\u0443 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432:<\/p>\n<pre><code class=\"python\">import pytest   def idfn_x(val):     return &quot;x=({0})&quot;.format(str(val))      def idfn_y(val):     return &quot;y=({0})&quot;.format(str(val))   @pytest.mark.parametrize(&quot;x&quot;, [-1,2], ids=idfn_x) @pytest.mark.parametrize(&quot;y&quot;, [-10,11], ids=idfn_y) def test_cross_params(x, y):     print &quot;x: {0}, y: {1}&quot;.format(x, y)     assert True      @pytest.mark.parametrize(&quot;x&quot;, [-1,2], ids=[&quot;negative x&quot;,&quot;positive y&quot;]) @pytest.mark.parametrize(&quot;y&quot;, [-10,11], ids=[&quot;negative y&quot;,&quot;positive y&quot;]) def test_cross_params_2(x, y):     print &quot;x: {0}, y: {1}&quot;.format(x, y)     assert True <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v parametrizing_combinations_named.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp\/, inifile: collected 8 items  parametrizing_combinations_named.py::test_cross_params[y=(-10)-x=(-1)] x: -1, y: -10 PASSED parametrizing_combinations_named.py::test_cross_params[y=(-10)-x=(2)] x: 2, y: -10 PASSED parametrizing_combinations_named.py::test_cross_params[y=(11)-x=(-1)] x: -1, y: 11 PASSED parametrizing_combinations_named.py::test_cross_params[y=(11)-x=(2)] x: 2, y: 11 PASSED parametrizing_combinations_named.py::test_cross_params_2[negative y-negative x] x: -1, y: -10 PASSED parametrizing_combinations_named.py::test_cross_params_2[negative y-positive y] x: 2, y: -10 PASSED parametrizing_combinations_named.py::test_cross_params_2[positive y-negative x] x: -1, y: 11 PASSED parametrizing_combinations_named.py::test_cross_params_2[positive y-positive y] x: 2, y: 11 PASSED ========================== 8 passed in 0.04 seconds <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0412\u044b\u0437\u043e\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0444\u0438\u043a\u0441\u0442\u0443\u0440 \u0438 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b<\/h4>\n<p>  PyTest \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0438\u043a\u0441\u0442\u0443\u0440 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430.<\/p>\n<pre><code class=\"python\">import pytest   @pytest.fixture() def fixture1(request):     print(&quot;fixture1&quot;)      @pytest.fixture() def fixture2(request):     print(&quot;fixture2&quot;)      @pytest.fixture() def fixture3(request):     print(&quot;fixture3&quot;)      def test_1(fixture1, fixture2):     print(&quot;test_1&quot;)   def test_2(fixture1, fixture2, fixture3):     print(&quot;test_2&quot;) <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v multiply_fixtures.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp, inifile: collected 2 items  multiply_fixtures.py::test_1 fixture1 fixture2 test_1 PASSED multiply_fixtures.py::test_2 fixture1 fixture2 fixture3 test_2 PASSED ========================== 2 passed in 0.01 seconds <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043b\u044e\u0431\u0430\u044f \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u0430 \u043c\u043e\u0436\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u043b\u044e\u0431\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0438\u043a\u0441\u0442\u0443\u0440 \u0434\u043e \u0441\u0435\u0431\u044f:<\/p>\n<pre><code class=\"python\">import pytest   @pytest.fixture() def fixture1(request, fixture2):     print(&quot;fixture1&quot;)      @pytest.fixture() def fixture2(request, fixture3):     print(&quot;fixture2&quot;)      @pytest.fixture() def fixture3(request):     print(&quot;fixture3&quot;)      def test_1(fixture1):     print(&quot;test_1&quot;)   def test_2(fixture2):     print(&quot;test_2&quot;) <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v fixtures_use_fixtures.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp, inifile: collected 2 items  fixtures_use_fixtures.py::test_1 fixture3 fixture2 fixture1 test_1 PASSED fixtures_use_fixtures.py::test_2 fixture3 fixture2 test_2 PASSED ========================== 2 passed in 0.01 seconds  <\/code><\/pre>\n<p>  <\/p>\n<h4>\u041c\u0435\u0442\u043a\u0438<\/h4>\n<p>  PyTest \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432  @pytest.mark \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u00ab\u043c\u0435\u0442\u043a\u0430\u043c\u0438\u00bb (marks). \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043a\u0438:<\/p>\n<p>  1)  @pytest.mark.parametrize \u2014 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 (\u0431\u044b\u043b\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0432\u044b\u0448\u0435)<br \/>  2)  @pytest.mark.xfail \u2013 \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0435\u0441\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0438 PyTest \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u044d\u0442\u043e, \u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 (\u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043a\u0430\u043a \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043c\u0435\u0442\u043a\u0430 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438). \u0422\u0430\u043a\u0436\u0435 \u044d\u0442\u0430 \u043c\u0435\u0442\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0442\u0435\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u0435\u0447\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u043a\u043e\u0439.<br \/>  3)  @pytest.mark.skipif \u2013 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043b \u0442\u0435\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d<br \/>  4)  @pytest.mark.usefixtures \u2013 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430<\/p>\n<p>  \u0412\u043e\u043e\u0431\u0449\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u0448\u0438\u0440\u0435 \u0438 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u00abpy.test &#8212;markers\u00bb.<\/p>\n<pre><code class=\"python\">import pytest import sys   @pytest.mark.xfail() def test_failed():     assert False      @pytest.mark.xfail(sys.platform != &quot;win64&quot;, reason=&quot;requires windows 64bit&quot;) def test_failed_for_not_win32_systems():     assert False      @pytest.mark.skipif(sys.platform != &quot;win64&quot;, reason=&quot;requires windows 64bit&quot;) def test_skipped_for_not_win64_systems():     assert False <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v basic_marks.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp, inifile: collected 3 items  basic_marks.py::test_failed xfail basic_marks.py::test_failed_for_not_win32_systems xfail basic_marks.py::test_skipped_for_not_win64_systems SKIPPED ==================== 1 skipped, 2 xfailed in 0.02 seconds <\/code><\/pre>\n<p>  \u0412\u0430\u0436\u043d\u044b\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043c\u0435\u0442\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e \u0437\u0430\u0434\u0430\u043d\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u0427\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0430\u0431\u043e\u0440\u044b \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u043c\u0435\u0442\u043a\u0438, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0435\u0435 \u0441 \u043a\u043b\u044e\u0447\u0435\u043c -m.<\/p>\n<pre><code class=\"python\">import pytest   def test_1():     print &quot;test_1&quot;      @pytest.mark.critital_tests def test_2():     print &quot;test_2&quot;      def test_3():     print &quot;test_3&quot; <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v -m &quot;critital_tests&quot; custom_marks.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp, inifile: collected 3 items  custom_marks.py::test_2 test_2 PASSED ================= 2 tests deselected by &quot;-m 'critital_tests'&quot; ================= =================== 1 passed, 2 deselected in 0.01 seconds ==================== <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0447\u0435\u0440\u0435\u0437 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0435\u0435 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435 pytest.ini. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u043a, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u00abpy.test &#8212;markers\u00bb.<\/p>\n<p>  <i>pytest.ini<\/i><\/p>\n<pre><code class=\"python\"># content of pytest.ini [pytest] markers =     critical_test: mark test as critical. These tests must to be checked first. <\/code><\/pre>\n<pre><code class=\"diff\">tmp&gt;py.test --markers @pytest.mark.critical_test: mark test as critical. These tests must to be checked first. \u2026...... <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043c\u0435\u0442\u043a\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0441\u0442, \u043d\u043e \u0438 \u043a\u043b\u0430\u0441\u0441, \u043c\u043e\u0434\u0443\u043b\u044c (\u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f) \u0438\u043b\u0438 \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0430\u0446\u0438\u044e (\u0441\u043c. \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440).<\/p>\n<pre><code class=\"python\">import pytest  pytestmark = pytest.mark.level1   def test_1():     print &quot;test_1&quot;      @pytest.mark.level2 class TestClass:     def test_2(self):         print &quot;test_2&quot;     @pytest.mark.level3     def test_3(self):         print &quot;test_3&quot; <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v -m &quot;level3&quot; custom_marks_others.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp, inifile: pytest.ini collected 3 items  custom_marks_others.py::TestClass::test_3 test_3 PASSED ===================== 2 tests deselected by &quot;-m 'level3'&quot; ===================== =================== 1 passed, 2 deselected in 0.07 seconds ==================== <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v -m &quot;level2&quot; custom_marks_others.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp, inifile: pytest.ini collected 3 items  custom_marks_others.py::TestClass::test_2 test_2 PASSED custom_marks_others.py::TestClass::test_3 test_3 PASSED ===================== 1 tests deselected by &quot;-m 'level2'&quot; ===================== =================== 2 passed, 1 deselected in 0.03 seconds ==================== <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v -m &quot;level1&quot; custom_marks_others.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp, inifile: pytest.ini collected 3 items  custom_marks_others.py::test_1 test_1 PASSED custom_marks_others.py::TestClass::test_2 test_2 PASSED custom_marks_others.py::TestClass::test_3 test_3 PASSED ========================== 3 passed in 0.02 seconds =========================== <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">import pytest  @pytest.mark.parametrize((&quot;x&quot;,&quot;expected&quot;), [ (1,2), pytest.mark.critical((2,3)), (3,4) ]) def test_inc(x,expected):     print x, &quot;+ 1 = &quot;, expected     assert x + 1 == expected <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v -m &quot;critical&quot; custom_marks_params.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp, inifile: pytest.ini collected 3 items  custom_marks_params.py::test_inc[2-3] 2 + 1 =  3 PASSED ==================== 2 tests deselected by &quot;-m 'critical'&quot; ==================== =================== 1 passed, 2 deselected in 0.02 seconds ==================== <\/code><\/pre>\n<p>  <\/p>\n<h4>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439<\/h4>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043a\u0430\u043a \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, PyTest \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u00abwith pytest.raises()\u00bb.<\/p>\n<pre><code class=\"python\">import pytest  def f():     print 1\/0  def test_exception():     with pytest.raises(ZeroDivisionError):         f() <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v check_exception.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp, inifile: pytest.ini collected 1 items  check_exception.py::test_exception PASSED ========================== 1 passed in 0.01 seconds  <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0417\u0430\u043f\u0443\u0441\u043a \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0438\u043b\u0438 ID<\/h4>\n<p>  \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u044f \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u043d\u0438\u043c \u0432 \u0432\u0438\u0434\u0435 module.py::class::method \u0438\u043b\u0438. module.py::function. \u0410 \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0441 \u0444\u043b\u0430\u0433\u043e\u043c -k \u0447\u0430\u0441\u0442\u044c \u0438\u0445 \u0438\u043c\u0435\u043d\u0438.<\/p>\n<pre><code class=\"python\">import pytest  def test_one():     print &quot;test_one&quot;  def test_one_negative():     print &quot;test_one_negative&quot;      def test_two():     print &quot;test_one_negative&quot; <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v call_by_name_and_id.py::test_two ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp, inifile: pytest.ini collected 4 items  call_by_name_and_id.py::test_two test_one_negative PASSED ========================== 1 passed in 0.04 seconds  <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"diff\">tmp&gt;py.test -s -v -k &quot;one&quot; call_by_name_and_id.py ============================= test session starts ============================= platform win32 -- Python 2.7.8, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 -- c:\\prog ram files (x86)\\python27\\python.exe cachedir: .cache rootdir: tmp, inifile: pytest.ini collected 3 items  call_by_name_and_id.py::test_one test_one PASSED call_by_name_and_id.py::test_one_negative test_one_negative PASSED ======================== 1 tests deselected by '-kone' ======================== =================== 2 passed, 1 deselected in 0.01 seconds ==================== <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441 PyDev \u0432 Eclipse<\/h4>\n<p>  \u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c, \u0447\u0442\u043e PyTest \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 PyUnit \u043c\u043e\u0434\u0443\u043b\u044f PyDev \u0434\u043b\u044f Eclipse. \u041f\u0440\u043e\u0441\u0442\u043e \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043d\u0430\u0434\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fe6\/444\/970\/fe644497062949e9835aed229e8a5a46.jpg\" alt=\"image\"\/><\/p>\n<h4>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438<\/h4>\n<p>  PyTest \u0438\u043c\u0435\u0435\u0442 \u043c\u0430\u0441\u0441\u0443 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 <a href=\"http:\/\/pytest.org\/latest\/plugins_index\/index.html\">\u043c\u043e\u0434\u0443\u043b\u0435\u0439<\/a>.<br \/>  \u041c\u043e\u0433\u0443 \u043b\u0438\u0448\u044c \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u0442\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u043d\u044f \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0438 \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 (\u0434\u0435\u0442\u0430\u043b\u0438 \u043e \u043c\u043e\u0434\u0443\u043b\u044f\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0432\u044b\u0448\u0435):<\/p>\n<p>  <i>pytest-describe<\/i> \u2013 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 (\u043c\u043e\u0434\u0443\u043b\u044c-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435-\u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u0430\u043a \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442 \u043c\u043e\u0434\u0443\u043b\u044c-\u0444\u0443\u043d\u043a\u0446\u0438\u044f-testcase).<\/p>\n<p>  <i>pytest-instafail<\/i> \u2013 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u044f \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0447\u0442\u043e \u0432\u0441\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0430 \u043d\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044e \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0441\u0435\u0439 \u0441\u0435\u0441\u0441\u0441\u0438\u0438.<\/p>\n<p>  <i>pytest-marks<\/i> \u2013 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u043a \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code class=\"python\">@pytest.mark.red @pytest.mark.green @pytest.mark.blue def some_test_method(self): ..... <\/code><\/pre>\n<p>  <i>pytest-ordering<\/i> \u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043a\u0443 Run.<\/p>\n<pre><code class=\"python\">import pytest  @pytest.mark.run(order=2) def test_foo():     assert True  @pytest.mark.run(order=1) def test_bar():     assert True <\/code><\/pre>\n<p>  <i>pytest-pep8<\/i> \u2013 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u043e\u0434 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f pep-8.<\/p>\n<p>  <i>pytest-smartcov<\/i> \u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u043a\u043e\u0434\u0430 \u0442\u0435\u0441\u0442\u0430\u043c, \u043a\u0430\u043a \u043f\u043e\u043b\u043d\u043e\u0435, \u0442\u0430\u043a \u0438 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0435.<\/p>\n<p>  <i>pytest-timeout<\/i> \u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043f\u043e \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0443, \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043b\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0435\u0442\u043a\u0438.<\/p>\n<p>  <i>pytest-sugar<\/i> \u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u0432\u044b\u0432\u043e\u0434\u0430 PyTest&#8217;\u0430, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u0431\u0430\u0440 \u0438 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0440\u0430\u0441\u0438\u0432\u043e, \u043f\u0443\u0441\u043a\u0430\u0439 \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e.<\/p>\n<h4>\u041f\u043e\u0441\u043b\u0435\u0441\u043b\u043e\u0432\u0438\u0435<\/h4>\n<p>  \u0412 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 PyTest \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043f\u043e \u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e. \u041d\u043e \u043e \u043d\u0438\u0445 \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437: \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c PyTest (\u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0442\u0435\u0441\u0442\u044b, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0445 \u043e\u043f\u0446\u0438\u0439 \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438), \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0441\u0431\u043e\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0430\u0446\u0438\u0438 (\u043e\u0431\u044a\u0435\u043a\u0442 metafunc) \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435.       <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/269759\/\"> http:\/\/habrahabr.ru\/post\/269759\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<br \/>\n<h4>\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h4>\n<p>  \u041f\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043f\u0440\u0438\u0437\u0432\u0430\u043d\u0438\u044e \u044f SQL-\u0449\u0438\u043a. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0443\u0434\u044c\u0431\u0430 \u0437\u0430\u043d\u0435\u0441\u043b\u0430 \u043c\u0435\u043d\u044f \u043d\u0430 BigData \u0438 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043d\u0435\u0441\u043b\u0430 \u043a\u0440\u0438\u0432\u0430\u044f \u2014 \u044f \u043e\u0441\u0432\u043e\u0438\u043b \u0438 Java, \u0438 Python, \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 Scala \u0441\u0442\u043e\u0438\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435). \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043a\u0443\u0441\u043a\u043e\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u0441\u0442\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u043d\u0430 Python. \u0420\u0435\u0431\u044f\u0442\u0430 \u0438\u0437 QA \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b\u0438 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 PyTest, \u043d\u043e \u0434\u0430\u0436\u0435 \u043e\u043d\u0438 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0438\u043b\u0438\u0441\u044c \u0442\u043e\u043b\u043a\u043e\u043c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0447\u0435\u043c \u044d\u0442\u043e\u0442 \u0437\u0432\u0435\u0440\u044c \u0445\u043e\u0440\u043e\u0448. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0432\u043e\u043f\u0440\u043e\u0441\u0443 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043c\u043d\u043e\u0433\u043e: <a href=\"http:\/\/habrahabr.ru\/company\/yandex\/blog\/242795\/\">\u043a\u0430\u043a \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0432 Yandex<\/a> \u0434\u0430 \u0438 \u0432\u0441\u0435 \u043f\u043e-\u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432 \u044d\u0442\u043e\u043c \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0434\u043b\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0442\u0435\u0437\u0435. \u041d\u0435 \u0433\u043e\u0432\u043e\u0440\u044f \u0443\u0436\u0435 \u043e\u0431 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u2014 \u043e\u043d\u0430 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u043b\u0430 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u0441\u043c\u044b\u0441\u043b \u043b\u0438\u0448\u044c \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u0441 \u0441\u0430\u043c\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c. \u041d\u0435 \u0441\u043f\u043e\u0440\u044e, \u0442\u0430\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0432\u0435\u0449\u0438, \u043d\u043e, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u0442\u0430.<\/p>\n<h4>\u042e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 Python<\/h4>\n<p>  \u0427\u0442\u043e \u044d\u0442\u043e \u0438 \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043c\u044b\u0441\u043b\u0430 \u043d\u0435 \u0432\u0438\u0436\u0443 \u2014 \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u044f \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0437\u043d\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435. \u041f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0434\u043b\u044f Python <a href=\"http:\/\/habrahabr.ru\/post\/121162\">\u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0430 \u0425\u0430\u0431\u0440\u0435<\/a>.<\/p>\n<h4>\u0412\u0432\u043e\u0434\u043d\u0430\u044f \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0437\u043d\u0430\u043d\u0438\u044f\u043c<\/h4>\n<p>  \u041d\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u043d\u0430\u043d\u0438\u044f Python \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u044b \u2014 \u044f \u043f\u0438\u0441\u0430\u043b \u043a\u043e\u0435-\u043a\u0430\u043a\u0438\u0435 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0438 \u0437\u043d\u0430\u043b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0432\u0435\u0449\u0438. \u041d\u043e \u043f\u0440\u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u0441 PyTest \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0431\u0430\u0433\u0430\u0436 \u0437\u043d\u0430\u043d\u0438\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/141411\/\">\u0442\u0443\u0442<\/a> \u0438 <a href=\"http:\/\/habrahabr.ru\/post\/141501\/\">\u0442\u0443\u0442<\/a> \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 <a href=\"http:\/\/habrahabr.ru\/post\/132554\/\">yield<\/a>.<\/p>\n<h4>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 PyTest<\/h4>\n<p>  1) \u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 API (no boilerplate). \u041a\u0430\u043a \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u0442\u043e\u043c \u0436\u0435 unittest:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">import unittest  class TestUtilDate(unittest.TestCase):     def setUp(self):         #init_something()         pass              def tearDown(self):         #teardown_something()         pass              def test_upper(self):         self.assertEqual('foo'.upper(), 'FOO')              def test_isupper(self):         self.assertTrue('FOO'.isupper())              def test_failed_upper(self):         self.assertEqual('foo'.upper(), 'FOo')          if __name__ == '__main__':     suite = unittest.TestLoader().loadTestsFromTestCase(TestUtilDate)     unittest.TextTestRunner(verbosity=2).run(suite) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0432 PyTest:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">import pytest  def setup_module(module):     #init_something()     pass  def teardown_module(module):     #teardown_something()     pass  def test_upper():     assert 'foo'.upper() == 'FOO'      def test_isupper():     assert 'FOO'.isupper()      def test_failed_upper():     assert 'foo'.upper() == 'FOo' <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  2) \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u043e\u0442\u0447\u0435\u0442. \u0412 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0432 JUnitXML (\u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0441 Jenkins). \u0421\u0430\u043c \u0432\u0438\u0434 \u043e\u0442\u0447\u0435\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0446\u0432\u0435\u0442\u0430) \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438 (\u043e \u043d\u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e). \u041d\u0443 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0446\u0432\u0435\u0442\u043d\u043e\u0439 \u043e\u0442\u0447\u0435\u0442 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u2014 \u043a\u0440\u0430\u0441\u043d\u044b\u0435 FAILED \u0432\u0438\u0434\u043d\u044b \u0441\u0440\u0430\u0437\u0443.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/7e1\/4f3\/b8b\/7e14f3b8b89a4aac849e98432b098e98.jpg\" alt=\"image\"\/><\/p>\n<p>  3) \u0423\u0434\u043e\u0431\u043d\u044b\u0439 asset (\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0438\u0437 Python). \u041d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0433\u043e\u043b\u043e\u0432\u0435 \u0432\u0441\u044e \u043a\u0443\u0447\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 assert&#8217;\u043e\u0432.<\/p>\n<p>  4) \u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b \u0432\u0441\u0435\u0445 \u0443\u0440\u043e\u0432\u043d\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>  5) \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0444\u0438\u043a\u0441\u0442\u0443\u0440 (\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b, \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043e\u0431\u044a\u0435\u043a\u0442 request, \u0430\u0432\u0442\u043e\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b)<\/p>\n<p>  6) \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432, \u0442\u043e \u0435\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0442\u0435\u0441\u0442\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043d\u0430\u0431\u043e\u0440\u0430\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0412\u043e\u043e\u0431\u0449\u0435 \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043f\u0443\u043d\u043a\u0442\u0443 5 \u00ab\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u00bb, \u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0440\u043e\u0448\u0430, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u043e\u0439\u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430.<\/p>\n<p>  7) \u041c\u0435\u0442\u043a\u0438 (marks), \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0442\u0435\u0441\u0442, \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u0442\u0435\u0441\u0442, \u043a\u0430\u043a \u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 (\u0438 \u044d\u0442\u043e \u0435\u0433\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435) \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0442\u0435\u0441\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0433\u043e \u043f\u043e \u0438\u043c\u0435\u043d\u0438.<\/p>\n<p>  8) \u041f\u043b\u0430\u0433\u0438\u043d\u044b. \u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  9) \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 unittest \u0438 nose, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0441 \u043d\u0438\u043c\u0438.<\/p>\n<p>  \u041f\u0440\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438, \u043f\u0443\u0441\u0442\u044c \u0438\u0445 \u0438 \u043d\u0435 \u043c\u043d\u043e\u0433\u043e, \u043c\u043e\u0433\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  1) \u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438: \u0414\u043b\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u0435\u0441\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c. \u041d\u043e \u043b\u043e\u0433\u0438\u043a\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f testcase, \u043a\u043e\u0433\u0434\u0430 \u0442\u0430 \u0436\u0435 \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e testcase&#8217;\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u043e\u0437\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438 \u043e\u0448\u0438\u0431\u043e\u043a). \u042d\u0442\u043e \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u043a\u043e\u043c\u043f\u0435\u043d\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u043c (\u043f\u043b\u0430\u0433\u0438\u043d\u043e\u043c) pytest-describe, \u043d\u043e \u0442\u0430\u043c \u0432\u0441\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0444\u0438\u043a\u0441\u0442\u0443\u0440\u044b (scope = \u201cdescribe\u201d). \u0421 \u044d\u0442\u0438\u043c \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0436\u0438\u0442\u044c, \u043d\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f PyTest \u2014 \u00ab\u0432\u0441\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430\u00bb.<\/p>\n<p>  2) \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u043e\u0434\u0443\u043b\u044f, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435. \u0412\u0441\u0435-\u0442\u0430\u043a\u0438 unittest \u0438 doctest \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 Python \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u043b\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>  3) \u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f PyTest \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u043d\u0430\u043d\u0438\u0439 Python, \u0447\u0435\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0436\u0435 unittest (\u0441\u043c. \u00ab\u0412\u0432\u043e\u0434\u043d\u0430\u044f \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u00bb).<\/p>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u044f \u0438 \u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-267043","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/267043","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=267043"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/267043\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=267043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=267043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=267043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}