{"id":2971,"date":"2023-10-08T13:40:33","date_gmt":"2023-10-08T04:40:33","guid":{"rendered":"https:\/\/edu.ujhb.org\/?p=2971"},"modified":"2023-10-08T13:40:33","modified_gmt":"2023-10-08T04:40:33","slug":"pytest%e5%85%a5%e9%96%80","status":"publish","type":"post","link":"https:\/\/edu.ujhb.org\/?p=2971","title":{"rendered":"pytest\u5165\u9580"},"content":{"rendered":"\n<p>pytest\u306e\u4e2d\u56fd\u8a9e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u3084\u308a\u305f\u3044\u306e\u3067\u3059\u304c\u3001\u6700\u521d\u306b\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30ebChatGPT\u306e\u6982\u8981\u3092\u6559\u3048\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306b\u3064\u3044\u3066\u4e2d\u56fd\u8a9e\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u306f\u3001\u7279\u306b\u6bcd\u56fd\u8a9e\u304c\u4e2d\u56fd\u8a9e\u3067\u3042\u308bIT\u5b66\u7fd2\u8005\u306b\u3068\u3063\u3066\u306f\u826f\u3044\u8003\u3048\u3067\u3059\u3002 \u8003\u3048\u3089\u308c\u308b\u6982\u8981\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<code>pytest<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Pytest\u4e2d\u56fd\u8a9e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u6982\u8981<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1. \u30a4\u30f3\u30c8\u30ed\u30c0\u30af\u30b7\u30e7\u30f3<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u3068\u306f<code>pytest<\/code><\/li>\n\n\n\n<li><code>pytest<\/code>\u4ed6\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3068\u306e\u6bd4\u8f03<\/li>\n\n\n\n<li>\u9078\u3076\u7406\u7531<code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2. \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3068\u8a2d\u5b9a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5<code>pytest<\/code><\/li>\n\n\n\n<li>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u521d\u671f\u5316\u3059\u308b<code>pytest<\/code><\/li>\n\n\n\n<li>\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u306e\u89e3\u91c8<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3. \u57fa\u672c\u7684\u306a\u8003\u3048\u65b9<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30c6\u30b9\u30c8_\u30b1\u30fc\u30b9<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u30d5\u30a3\u30af\u30b9\u30c1\u30e3(\u30d5\u30a3\u30af\u30b9\u30c1\u30e3)<\/li>\n\n\n\n<li>\u65ad\u8a00\uff08Assertions\uff09<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">4.\u6700\u521d\u306e\u30c6\u30b9\u30c8\u3092\u66f8\u304f<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5358\u7d14\u306a\u95a2\u6570\u3092\u4f5c\u6210\u3059\u308b<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u3092\u66f8\u304f<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">5.\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3059\u308b<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3068\u306f<\/li>\n\n\n\n<li>\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u4f5c\u6210\u65b9\u6cd5\u3068\u4f7f\u7528\u65b9\u6cd5<\/li>\n\n\n\n<li>\u5099\u54c1\u306e\u7bc4\u56f2<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">6. \u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u691c\u5b9a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u691c\u5b9a\u3068\u306f<\/li>\n\n\n\n<li>\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u691c\u5b9a\u306e\u5b9f\u884c\u65b9\u6cd5<\/li>\n\n\n\n<li>\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">7. \u30de\u30fc\u30af\u3068\u30e9\u30d9\u30eb<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30de\u30fc\u30af\u306b\u4f7f\u7528<code>pytest.mark<\/code><\/li>\n\n\n\n<li>\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0<\/li>\n\n\n\n<li>\u7279\u5b9a\u306e\u30bf\u30b0\u306e\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">8. \u4f8b\u5916\u3092\u51e6\u7406\u3059\u308b<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f8b\u5916\u51e6\u7406\u306e\u4f7f\u7528<code>pytest.raises<\/code><\/li>\n\n\n\n<li>\u51e6\u7406\u306e\u8b66\u544a\u3092\u4f7f\u7528\u3059\u308b<code>pytest.warns<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">9. \u30d7\u30e9\u30b0\u30a4\u30f3\u3068\u62e1\u5f35\u6a5f\u80fd<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e00\u822c\u7684\u306b\u4f7f\u7528\u3055\u308c\u308b\u30d7\u30e9\u30b0\u30a4\u30f3<code>pytest<\/code><\/li>\n\n\n\n<li>\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u4f7f\u7528\u3059\u308b\u65b9\u6cd5<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">10.\u9ad8\u5ea6\u306a\u30c6\u30fc\u30de<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e26\u5217\u30c6\u30b9\u30c8<\/li>\n\n\n\n<li>\u30b3\u30de\u30f3\u30c9 \u30e9\u30a4\u30f3 \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3059\u308b<\/li>\n\n\n\n<li>CI\/CD \u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3078\u306e\u7d71\u5408<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">11. \u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30b3\u30fc\u30c9\u7de8\u6210<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u30ab\u30d0\u30ec\u30c3\u30b8<\/li>\n\n\n\n<li>\u30ed\u30b0\u3068\u30ec\u30dd\u30fc\u30c8<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">12. \u7d50\u8ad6\u3068\u6b21\u306e\u30b9\u30c6\u30c3\u30d7<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6982\u8981<\/li>\n\n\n\n<li>\u305d\u306e\u4ed6\u306e\u5b66\u7fd2\u30ea\u30bd\u30fc\u30b9<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u866b\u5782<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u3088\u304f\u3042\u308b\u3054\u8cea\u554f<\/li>\n\n\n\n<li>\u30ea\u30bd\u30fc\u30b9<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u306e\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u306f\u6bd4\u8f03\u7684\u57fa\u672c\u7684\u306a\u3082\u306e\u3067\u3042\u308a\u3001\u5bfe\u8c61\u8005\u3084\u76ee\u7684\u306b\u5fdc\u3058\u3066\u8abf\u6574\u3067\u304d\u307e\u3059\u3002 \u3053\u308c\u304c\u4e2d\u56fd\u8a9e\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u59cb\u3081\u308b\u306e\u306b\u5f79\u7acb\u3064\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059! \u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092YouTube\u306b\u6295\u7a3f\u3059\u308b\u4e88\u5b9a\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u3088\u308a\u591a\u304f\u306eIT\u5b66\u7fd2\u8005\u3084\u6f5c\u5728\u7684\u306a\u9867\u5ba2\u306b\u30ea\u30fc\u30c1\u3059\u308b\u305f\u3081\u306e\u512a\u308c\u305f\u65b9\u6cd5\u306b\u3082\u306a\u308a\u307e\u3059\u3002<code>pytest<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u306f\u3058\u3081\u306bpytestChatGPT\u3068\u306f\u4f55\u304b\u3092\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u306f\u3058\u3081\u306b\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u4f7f\u7528\u3067\u304d\u308b\u300cpytest\u3068\u306f\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d1\u30a4\u30c6\u30b9\u30c8\u3068\u306f<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p><code>pytest<\/code>&nbsp;\u306f\u3001Python\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u7528\u306e\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002 \u30b7\u30f3\u30d7\u30eb\u3067\u62e1\u5f35\u53ef\u80fd\u306a\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u3092\u66f8\u304f\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u3001\u8c4a\u5bcc\u306a\u30d7\u30e9\u30b0\u30a4\u30f3\u30b9\u30bf\u30c3\u30af\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e3b\u306a\u6a5f\u80fd<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u30b7\u30f3\u30d7\u30eb\u3055<\/strong>:\u3053\u308c\u306b\u3088\u308a\u3001\u5358\u7d14\u306a\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3068\u81ea\u52d5\u691c\u51fa\u30c6\u30b9\u30c8\u3092\u4f7f\u7528\u3067\u304d\u308b\u305f\u3081\u3001\u591a\u304f\u306e\u5b9a\u578b\u30b3\u30fc\u30c9\u3092\u56de\u907f\u3067\u304d\u307e\u3059\u3002<code>pytest<\/code><code>assert<\/code><\/li>\n\n\n\n<li><strong>\u67d4\u8edf\u6027<\/strong>:\u5358\u4f53\u30c6\u30b9\u30c8\u3001\u7d71\u5408\u30c6\u30b9\u30c8\u3001\u30a8\u30f3\u30c9\u30c4\u30fc\u30a8\u30f3\u30c9\u30c6\u30b9\u30c8\u306a\u3069\u306b\u4f7f\u7528\u3067\u304d\u3001\u307b\u307c\u3059\u3079\u3066\u306e\u30bf\u30a4\u30d7\u306e\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306e\u30c6\u30b9\u30c8\u304c\u53ef\u80fd\u3067\u3059\u3002<code>pytest<\/code><\/li>\n\n\n\n<li><strong>\u8c4a\u5bcc\u306a\u30d7\u30e9\u30b0\u30a4\u30f3\u30b7\u30b9\u30c6\u30e0<\/strong>:\u30b5\u30fc\u30c9\u30d1\u30fc\u30c6\u30a3\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u591a\u6570\u3042\u308a\u3001\u72ec\u81ea\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u958b\u767a\u3059\u308b\u306e\u3082\u7c21\u5358\u3067\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u30c6\u30b9\u30c8\u306e\u7a2e\u985e<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5358\u4f53\u30c6\u30b9\u30c8<\/strong>: \u30c6\u30b9\u30c8\u53ef\u80fd\u306a\u6700\u5c0f\u306e\u90e8\u5206 (\u901a\u5e38\u306f\u95a2\u6570\u307e\u305f\u306f\u30e1\u30bd\u30c3\u30c9) \u3092\u30c6\u30b9\u30c8\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u6a5f\u80fd\u30c6\u30b9\u30c8<\/strong>:\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306e\u6a5f\u80fd\u306e\u5074\u9762\u3092\u30c6\u30b9\u30c8\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u7d71\u5408\u30c6\u30b9\u30c8<\/strong>: \u8907\u6570\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u307e\u305f\u306f\u30b7\u30b9\u30c6\u30e0\u306e\u7d71\u5408\u3092\u30c6\u30b9\u30c8\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a8\u30f3\u30c9\u30c4\u30fc\u30a8\u30f3\u30c9<\/strong>\u306e\u30c6\u30b9\u30c8: \u5b9f\u969b\u306e\u72b6\u6cc1\u3067\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5168\u4f53\u306e\u52d5\u4f5c\u3092\u30c6\u30b9\u30c8\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u4ed6\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3068\u306e\u6bd4\u8f03<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>OR\u3068\u6bd4\u8f03\u3057\u3066\u3001\u3088\u308a\u30af\u30ea\u30fc\u30f3\u306aAPI\u3068\u3088\u308a\u5f37\u529b\u306a\u6a5f\u80fd\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<code>unittest<\/code><code>nose<\/code><code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u4f7f\u7528\u30b7\u30ca\u30ea\u30aa<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Web \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30c6\u30b9\u30c8<\/li>\n\n\n\n<li>\u30c7\u30fc\u30bf\u30b5\u30a4\u30a8\u30f3\u30b9\/\u6a5f\u68b0\u5b66\u7fd2\u30e2\u30c7\u30eb\u306e\u691c\u8a3c<\/li>\n\n\n\n<li>\u30b9\u30af\u30ea\u30d7\u30c8\u691c\u8a3c\u306e\u81ea\u52d5\u5316<\/li>\n\n\n\n<li>\u539f\u85ac\u30c6\u30b9\u30c8<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u3068\u30b5\u30dd\u30fc\u30c8<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>pytest<\/code>\u8907\u6570\u306e\u30c1\u30e3\u30cd\u30eb(GitHub\u3001\u30b9\u30bf\u30c3\u30af\u30aa\u30fc\u30d0\u30fc\u30d5\u30ed\u30fc\u3001\u5c02\u7528\u30d5\u30a9\u30fc\u30e9\u30e0\u306a\u3069)\u3092\u901a\u3058\u3066\u30b5\u30dd\u30fc\u30c8\u3092\u53d7\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u8aac\u660e\u306f\u3001\u521d\u5fc3\u8005\u304c\u57fa\u672c\u7684\u306a\u6982\u5ff5\u3068\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 \u30b7\u30ca\u30ea\u30aa\u3092\u7406\u89e3\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u4e00\u90e8\u3068\u3057\u3066\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002 \u304a\u5f79\u306b\u7acb\u3066\u308c\u3070!<code>pytest<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>ChatGPT\u306e\u4ed6\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3068\u6bd4\u8f03\u3057\u305fpytest\u306e\u5c0e\u5165\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ed6\u306e\u4e3b\u8981\u306aPython\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3068\u6bd4\u8f03\u3059\u308b\u305f\u3081\u306e\u8a73\u7d30\u306a\u8aac\u660e\u304c\u3042\u308a\u307e\u3059\u3002 \u3053\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u6982\u8981\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<code>pytest<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">pytest \u3068\u4ed6\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3068\u306e\u6bd4\u8f03<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1. \u5358\u4f53\u30c6\u30b9\u30c8<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u69cb\u6587<\/strong>: \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306e\u65b9\u6cd5\u3067\u30c6\u30b9\u30c8\u3092\u6574\u7406\u3059\u308b\u3068\u3001\u3088\u308a\u591a\u304f\u306e\u5b9a\u578b\u30b3\u30fc\u30c9\u306b\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002 \u3088\u308a\u7c21\u6f54\u306a\u95a2\u6570\u578b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30bf\u30a4\u30eb\u3092\u53ef\u80fd\u306b\u3057\u307e\u3059\u3002<code>unittest<\/code><code>pytest<\/code><\/li>\n\n\n\n<li>\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3:\u3001\u306a\u3069\u306e\u7279\u6b8a\u306a<strong>\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3<\/strong>\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308a\u3001\u3088\u308a\u81ea\u7136\u306a\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<code>unittest<\/code><code>assertEqual()<\/code><code>assertTrue()<\/code><code>pytest<\/code><code>assert<\/code><\/li>\n\n\n\n<li><strong>\u30c6\u30b9\u30c8\u691c\u51fa<\/strong>: \u3067\u59cb\u307e\u308b\u95a2\u6570\u306f\u81ea\u52d5\u7684\u306b\u691c\u51fa\u3067\u304d\u308b\u305f\u3081\u3001\u30c6\u30b9\u30c8 \u30b9\u30a4\u30fc\u30c8\u306b\u30c6\u30b9\u30c8\u3092\u624b\u52d5\u3067\u8ffd\u52a0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<code>pytest<\/code><code>test_<\/code><code>unittest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2.\u9f3b\/\u9f3b2<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9:\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u306f\u884c\u308f\u308c\u306a\u304f\u306a\u308a\u307e\u3057\u305f\u304c\u3001\u5f15\u304d\u7d9a\u304d\u9069\u5207\u306b<strong>\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9<\/strong>\u304a\u3088\u3073\u66f4\u65b0\u3055\u308c\u3066\u3044\u307e\u3059\u3002<code>nose<\/code><code>pytest<\/code><\/li>\n\n\n\n<li>\u30d7\u30e9\u30b0\u30a4\u30f3:\u8c4a\u5bcc\u306a\u30d7\u30e9\u30b0\u30a4\u30f3\u3082\u3042\u308a\u307e\u3059\u304c\u3001<strong>\u30d7\u30e9\u30b0\u30a4\u30f3<\/strong>\u30b7\u30b9\u30c6\u30e0\u306f\u3088\u308a\u30a2\u30af\u30c6\u30a3\u30d6\u3067\u591a\u69d8\u3067\u3059\u3002<code>nose<\/code><code>pytest<\/code><\/li>\n\n\n\n<li><strong>\u67d4\u8edf\u6027<\/strong>:\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30c6\u30b9\u30c8\u3001\u3088\u308a\u8907\u96d1\u306a\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306a\u3069\u306e\u3088\u308a\u9ad8\u5ea6\u306a\u6a5f\u80fd\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002<code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3. \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30c6\u30b9\u30c8<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u9069\u7528\u6027<\/strong>: \u5358\u7d14\u306a\u30c6\u30b9\u30c8 \u30b7\u30ca\u30ea\u30aa\u306b\u9069\u3057\u3066\u304a\u308a\u3001\u901a\u5e38\u306f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u57cb\u3081\u8fbc\u307e\u308c\u3066\u3044\u307e\u3059\u3002 \u3088\u308a\u8907\u96d1\u3067\u5305\u62ec\u7684\u306a\u30c6\u30b9\u30c8\u306e\u30cb\u30fc\u30ba\u306b\u9069\u3057\u3066\u3044\u307e\u3059\u3002<code>doctest<\/code><code>pytest<\/code><\/li>\n\n\n\n<li><strong>\u62e1\u5f35\u6027<\/strong>:\u30b9\u30b1\u30fc\u30e9\u30d3\u30ea\u30c6\u30a3\u306f\u30b9\u30b1\u30fc\u30e9\u30d3\u30ea\u30c6\u30a3\u3092\u5ff5\u982d\u306b\u7f6e\u3044\u3066\u8a2d\u8a08\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u304c\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u3084\u7d44\u307f\u8fbc\u307f\u6a5f\u80fd\u3092\u4f7f\u7528\u3057\u3066\u7c21\u5358\u306b\u62e1\u5f35\u3067\u304d\u307e\u3059\u3002<code>doctest<\/code><code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">4. TestNG\/JUnit(Java)<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u8a00\u8a9e\u306e\u5236\u9650<\/strong>: TestNG \u3068 JUnit \u306f Java \u7528\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u304c\u3001Python \u5c02\u7528\u306b\u8a2d\u8a08\u3055\u308c\u3066\u3044\u307e\u3059\u3002<code>pytest<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u3044\u3084\u3059\u3055:<\/strong>Java\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3068\u6bd4\u8f03\u3057\u3066\u3001\u7279\u306bJava\u30a8\u30b3\u30b7\u30b9\u30c6\u30e0\u306b\u7cbe\u901a\u3057\u3066\u3044\u306a\u3044\u4eba\u306b\u3068\u3063\u3066\u306f\u3001\u4e00\u822c\u7684\u306b\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3068\u4f7f\u7528\u304c\u7c21\u5358\u3067\u3059\u3002<code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">5. QUnit\/Mocha(JavaScript)<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u8a00\u8a9e\u306e\u5236\u9650<\/strong>:\u3053\u308c\u3089\u306fJavaScript\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3042\u308a\u3001\u3055\u307e\u3056\u307e\u306a\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<code>pytest<\/code><\/li>\n\n\n\n<li>\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3068\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306e\u5206\u96e2:\u30d5\u30eb\u30b9\u30bf\u30c3\u30af\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u4f5c\u696d\u3057\u3066\u3044\u308b\u5834\u5408\u306f\u3001<strong>\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3068\u30d0\u30c3\u30af\u30a8\u30f3\u30c9<\/strong>\u306e\u4e21\u65b9\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\u3002 \u3053\u308c\u306f\u3001\u30d0\u30c3\u30af\u30a8\u30f3\u30c9(Python)\u306b\u6700\u9069\u3067\u3059\u3002<code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u6bd4\u8f03\u306f\u3001\u521d\u5fc3\u8005\u304c\u4ed6\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u9577\u6240\u3068\u77ed\u6240\u3092\u3088\u308a\u5b8c\u5168\u306b\u628a\u63e1\u3057\u3066\u3001\u3088\u308a\u591a\u304f\u306e\u60c5\u5831\u306b\u57fa\u3065\u3044\u305f\u9078\u629e\u3092\u884c\u3046\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002 \u3053\u308c\u304c\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059\u3002<code>pytest<\/code><code>pytest<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u5c0e\u5165\u90e8\u3067pytestChatGPT\u304c\u9078\u3070\u308c\u305f\u7406\u7531\u3092\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u3053\u3053\u3067\u306f\u300c\u306a\u305c PyTest \u306a\u306e\u304b\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u304c\u3042\u308a\u307e\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u306f\u3058\u3081\u306b\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u306a\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u6a5f\u80fd\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u306a\u305c\u30d4\u30c6\u30b9\u30c8\u306a\u306e\u304b<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1.\u7c21\u6f54\u306a\u69cb\u6587<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>pytest<\/code>\u8907\u96d1\u306a\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u30e1\u30bd\u30c3\u30c9\u3092\u899a\u3048\u3066\u3044\u306a\u304f\u3066\u3082\u3001\u5358\u7d14\u306a\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u4f7f\u7528\u3057\u3066\u30a2\u30b5\u30fc\u30c8\u3067\u304d\u307e\u3059\u3002<code>assert<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2. \u81ea\u52d5\u30c6\u30b9\u30c8\u691c\u51fa<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7c21\u5358\u306a\u30b3\u30de\u30f3\u30c9\u3067\u3001\u305d\u308c\u304b\u3089\u59cb\u307e\u308b\u3059\u3079\u3066\u306e\u30c6\u30b9\u30c8\u6a5f\u80fd\u3092\u81ea\u52d5\u7684\u306b\u691c\u51fa\u3057\u3066\u5b9f\u884c\u3067\u304d\u308b\u305f\u3081\u3001\u30c6\u30b9\u30c8\u30b9\u30a4\u30fc\u30c8\u3092\u624b\u52d5\u3067\u6574\u7406\u3059\u308b\u5fc5\u8981\u304c\u306a\u304f\u306a\u308a\u307e\u3059\u3002<code>pytest<\/code><code>test_<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3.\u5f37\u529b\u306a\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u30b7\u30b9\u30c6\u30e0<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>pytest<\/code>\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u30b7\u30b9\u30c6\u30e0\u306f\u67d4\u8edf\u6027\u304c\u3042\u308a\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30c6\u30b9\u30c8\u3001\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u30c6\u30b9\u30c8\u306a\u3069\u306b\u5f79\u7acb\u3064\u30c6\u30b9\u30c8\u74b0\u5883\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u306b\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">4. \u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u691c\u5b9a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>pytest<\/code>\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u5316\u306e\u30b5\u30dd\u30fc\u30c8\u306b\u3088\u308a\u30011 \u3064\u306e\u30c6\u30b9\u30c8\u95a2\u6570\u3067\u8907\u6570\u306e\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u3092\u5b9f\u884c\u3067\u304d\u3001\u30b3\u30fc\u30c9\u306e\u518d\u5229\u7528\u304c\u5411\u4e0a\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">5.\u8c4a\u5bcc\u306a\u30d7\u30e9\u30b0\u30a4\u30f3\u30b7\u30b9\u30c6\u30e0<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5229\u7528\u53ef\u80fd\u306a\u30b5\u30fc\u30c9\u30d1\u30fc\u30c6\u30a3\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u306f\u591a\u6570\u3042\u308a\u3001\u72ec\u81ea\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u958b\u767a\u3059\u308b\u306e\u3082\u7c21\u5358\u3067\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">6.\u30af\u30ed\u30b9\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u304a\u3088\u3073\u7d99\u7d9a\u7684\u30a4\u30f3\u30c6\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u30b5\u30dd\u30fc\u30c8<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>pytest<\/code>\u307b\u307c\u3059\u3079\u3066\u306e\u30aa\u30da\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u30b7\u30b9\u30c6\u30e0\u3068Python\u74b0\u5883\u3067\u5b9f\u884c\u3055\u308c\u3001\u307b\u3068\u3093\u3069\u306eCI \/ CD\u30c4\u30fc\u30eb\u306b\u7c21\u5358\u306b\u7d71\u5408\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">7.\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u30b5\u30dd\u30fc\u30c8<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>pytest<\/code>\u5927\u898f\u6a21\u3067\u6d3b\u767a\u306a\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u3092\u6301\u3064\u3053\u3068\u306f\u3001\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u3068\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3092\u7c21\u5358\u306b\u898b\u3064\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">8.\u8907\u6570\u306e\u30c6\u30b9\u30c8\u30bf\u30a4\u30d7<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5358\u4f53\u30c6\u30b9\u30c8\u304b\u3089\u7d71\u5408\u30c6\u30b9\u30c8\u307e\u3067\u3001\u4e07\u80fd\u3067\u3059\u3002 API\u30c6\u30b9\u30c8\u3067\u3082Web UI\u30c6\u30b9\u30c8\u3067\u3082\u3001\u3042\u306a\u305f\u306f\u305d\u306e\u4ed5\u4e8b\u3092\u3057\u307e\u3059\u3002<code>pytest<\/code><code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">9.\u7c21\u5358\u306b\u59cb\u3081\u3089\u308c\u307e\u3059<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u521d\u5fc3\u8005\u3068\u7d4c\u9a13\u8c4a\u5bcc\u306a\u958b\u767a\u8005\u306e\u4e21\u65b9\u304c\u7c21\u5358\u306b\u59cb\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3068\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u30ea\u30bd\u30fc\u30b9\u3082\u975e\u5e38\u306b\u8c4a\u5bcc\u3067\u3059\u3002<code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">10.\u5546\u7528\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3068\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u4e21\u65b9\u306b\u9069\u7528\u53ef\u80fd<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5c0f\u898f\u6a21\u306a\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u3042\u308d\u3046\u3068\u5927\u898f\u6a21\u306a\u5546\u7528\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u3042\u308d\u3046\u3068\u3001\u4fe1\u983c\u3067\u304d\u308b\u9078\u629e\u80a2\u3067\u3059\u3002<code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u7406\u7531\u304c\u7d44\u307f\u5408\u308f\u3055\u3063\u3066\u3001Python\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306b\u6700\u9069\u3067\u3059\u3002 \u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u901a\u3058\u3066\u3001\u8996\u8074\u8005\u306f\u3001\u306a\u305c\u5b66\u7fd2\u3057\u3066\u4f7f\u7528\u3059\u308b\u4fa1\u5024\u304c\u3042\u308b\u306e\u304b \u3092\u3088\u308a\u660e\u78ba\u306b\u7406\u89e3\u3067\u304d\u307e\u3059\u3002 \u3053\u308c\u304c\u3042\u306a\u305f\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306b\u5f79\u7acb\u3064\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059!<code>pytest<\/code><code>pytest<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3068\u69cb\u6210\u3092\u4f7f\u7528\u3057\u3066pytestChatGPT\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u65b9\u6cd5\u3092\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300cpytest\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3068\u69cb\u6210\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u4e3b\u8981\u306a\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u6a5f\u80fd\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">pytest\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1. \u30b7\u30b9\u30c6\u30e0\u8981\u4ef6<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30b7\u30b9\u30c6\u30e0\u306b Python (\u30d0\u30fc\u30b8\u30e7\u30f3 3.6+ \u63a8\u5968) \u3068 pip (Python \u30d1\u30c3\u30b1\u30fc\u30b8 \u30de\u30cd\u30fc\u30b8\u30e3\u30fc) \u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2.pip\u3092\u4f7f\u7528\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30bf\u30fc\u30df\u30ca\u30eb\u3092\u958b\u304d\u307e\u3059(Windows\u30e6\u30fc\u30b6\u30fc\u306f\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u307e\u305f\u306fPowerShell\u3092\u4f7f\u7528\u3067\u304d\u3001Mac\u304a\u3088\u3073Linux\u30e6\u30fc\u30b6\u30fc\u306f\u30bf\u30fc\u30df\u30ca\u30eb\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059)\u3002<\/li>\n\n\n\n<li>\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u3066\u5b9f\u884c\u3057\u307e\u3059\u3002 \u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b: \u3053\u308c\u306b\u3088\u308a\u3001Python \u30d1\u30c3\u30b1\u30fc\u30b8 \u30a4\u30f3\u30c7\u30c3\u30af\u30b9 (PyPI) \u304b\u3089\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u304a\u3088\u3073\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059\u3002<code>pip install pytest&nbsp;<\/code><code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3. \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u78ba\u8a8d\u3059\u308b<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u3066\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u6210\u529f\u3057\u305f\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002 cssCopy \u30b3\u30fc\u30c9\u30d0\u30fc\u30b8\u30e7\u30f3\u60c5\u5831\u304c\u8868\u793a\u3055\u308c\u305f\u5834\u5408\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u6210\u529f\u3057\u3066\u3044\u307e\u3059\u3002<code>pytest --version&nbsp;<\/code><code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">4. (\u30aa\u30d7\u30b7\u30e7\u30f3) \u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>pytest<\/code>\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u306f\u305f\u304f\u3055\u3093\u3042\u308a\u307e\u3059: cssCopy \u30b3\u30fc\u30c9<code>pip install pytest-[\u63d2\u4ef6\u540d]<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">5. (\u7701\u7565\u53ef\u80fd) \u4eee\u60f3\u74b0\u5883\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u3084\u306a\u3069\u306e\u4eee\u60f3\u74b0\u5883\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u4e0a\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u524d\u306b\u3001\u307e\u305a\u4eee\u60f3\u74b0\u5883\u3092\u30a2\u30af\u30c6\u30a3\u30d6\u5316\u3057\u3066\u304f\u3060\u3055\u3044\u3002<code>venv<\/code><code>conda<\/code><code>pip<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">6. IDE\u306e\u7d71\u5408<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6700\u8fd1\u306e\u307b\u3068\u3093\u3069\u306eIDE(PyCharm\u3001VSCode\u306a\u3069)\u306f\u305d\u308c\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u304a\u308a\u3001IDE\u306e\u8a2d\u5b9a\u307e\u305f\u306f\u69cb\u6210\u3067\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3068\u3057\u3066\u9078\u629e\u3059\u308b\u3060\u3051\u3067\u3059\u3002<code>pytest<\/code><code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u521d\u5fc3\u8005\u304c\u3053\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u3088\u308a\u7c21\u5358\u306b\u4f7f\u3044\u59cb\u3081\u308b\u306e\u306b\u5f79\u7acb\u3064\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u624b\u9806\u3068\u3044\u304f\u3064\u304b\u306e\u8ffd\u52a0\u60c5\u5831\u3092\u542b\u3081\u3001\u3055\u307e\u3056\u307e\u306a\u74b0\u5883\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u304c\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059\u3002<code>pytest<\/code><code>pytest<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>pytest\u30d7\u30ed\u30b8\u30a7\u30af\u30c8ChatGPT\u306e\u521d\u671f\u5316\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3068\u69cb\u6210\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300cPytest\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u521d\u671f\u5316\u300d\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3068\u69cb\u6210\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u306a\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">pytest \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u521d\u671f\u5316\u3059\u308b<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1. \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3059\u308b<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30ef\u30fc\u30af\u30b9\u30da\u30fc\u30b9\u3067\u3001pytest \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30eb\u30fc\u30c8 \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3068\u3057\u3066\u65b0\u3057\u3044\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>mkdir my_pytest_project cd my_pytest_project<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2. \u4eee\u60f3\u74b0\u5883\u3092\u521d\u671f\u5316\u3059\u308b (\u30aa\u30d7\u30b7\u30e7\u30f3)<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5206\u96e2\u3055\u308c\u305f\u74b0\u5883\u3067\u4f9d\u5b58\u95a2\u4fc2\u3092\u7ba1\u7406\u3059\u308b\u5834\u5408\u306f\u3001\u4eee\u60f3\u74b0\u5883\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002\n<ul class=\"wp-block-list\">\n<li><strong>venv \u3092\u4f7f\u7528\u3057\u307e\u3059 (\u63a8\u5968<\/strong>)\u3002\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b<code>python3 -m venv venv<\/code>\n<ul class=\"wp-block-list\">\n<li>\u4eee\u60f3\u74b0\u5883\u3092\u30a2\u30af\u30c6\u30a3\u30d6\u5316\u3059\u308b\u306b\u306f:\n<ul class=\"wp-block-list\">\n<li><strong>Windows<\/strong>MathematicaCopy code<code>.\\venv\\Scripts\\Activate<\/code><\/li>\n\n\n\n<li><strong>Mac\/Linux<\/strong>bashCopy code<code>source venv\/bin\/activate<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>conda<\/strong>luaCopy \u30b3\u30fc\u30c9\u3092\u4f7f\u7528\u3059\u308b<code>conda create --name my_pytest_env python=3.8 conda activate my_pytest_env<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3.pytest\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>pytest\u3092\u307e\u3060\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u3001\u4eca\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068\u304d\u3067\u3059\u3002 \u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b<code>pip install pytest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">4. \u6700\u521d\u306e\u30c6\u30b9\u30c8 \u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8 \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3001\u901a\u5e38\u306f \u3067\u59cb\u307e\u308b\u65b0\u3057\u3044 Python \u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002 pythonCopy code<code>test_<\/code><code>test_example.py<\/code><code># \u5185\u5bb9\u793a\u4f8b def test_addition(): assert 1 + 1 == 2<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">5. \u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u30bf\u30fc\u30df\u30ca\u30eb\u3092\u958b\u304d\u3001\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002 \u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b \u3059\u3079\u3066\u304c\u6b63\u3057\u304f\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u3068\u5408\u683c\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">6.pytest\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3092\u8ffd\u52a0\u3057\u307e\u3059(\u30aa\u30d7\u30b7\u30e7\u30f3)<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u307e\u305f\u306f\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u56fa\u6709\u306e pytest \u8a2d\u5b9a\u3092\u4fdd\u5b58\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u00a0<code>pytest.ini<\/code><code>pyproject.toml<\/code>\n<ul class=\"wp-block-list\">\n<li><strong>pytest.ini<\/strong>&nbsp;iniCopy \u30b3\u30fc\u30c9\u306e\u4f8b<code>[pytest] addopts = --verbose<\/code><\/li>\n\n\n\n<li><strong>pyproject.toml \u30b5\u30f3\u30d7\u30eb toml<\/strong>\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>[tool.pytest.ini_options] addopts = \"--verbose\"<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">7. IDE\u7d71\u5408(\u30aa\u30d7\u30b7\u30e7\u30f3)<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PyCharm \u3084 VSCode \u306a\u3069\u306e IDE \u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u306f\u3001\u8a2d\u5b9a\u3067\u30c6\u30b9\u30c8 \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3068\u3057\u3066 pytest \u3092\u9078\u629e\u3057\u3001\u9069\u5207\u306a\u4eee\u60f3\u74b0\u5883 (\u4f7f\u7528\u53ef\u80fd\u306a\u5834\u5408) \u3092\u30dd\u30a4\u30f3\u30c8\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4f5c\u6210\u304b\u3089\u6700\u521d\u306e\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u307e\u3067\u3001\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u8a2d\u5b9a\u3092\u884c\u3046\u65b9\u6cd5\u306b\u3064\u3044\u3066\u9806\u3092\u8ffd\u3063\u3066\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u521d\u5fc3\u8005\u304cpytest\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u958b\u59cb\u3059\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3053\u308c\u304c\u3042\u306a\u305f\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306b\u5f79\u7acb\u3064\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>ChatGPT\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3068\u8a2d\u5b9a\u3092\u542b\u3080\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u8a73\u3057\u304f\u8aac\u660e<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u300c\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u8aac\u660e\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306f\u3053\u3061\u3089\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3068\u69cb\u6210\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u306e\u89e3\u91c8<\/h3>\n\n\n\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u306f\u3001\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u7528\u3057\u3066\u30c6\u30b9\u30c8\u306e\u52d5\u4f5c\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3067\u304d\u307e\u3059\u3002 \u6700\u3082\u4e00\u822c\u7684\u306b\u4f7f\u7528\u3055\u308c\u308b\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u306f \u3067\u3059\u304c\u3001\u307e\u305f\u306f\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<code>pytest<\/code><code>pytest.ini<\/code><code>pyproject.toml<\/code><code>setup.cfg<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1.\u30d1\u30a4\u30c6\u30b9\u30c8.ini<\/h4>\n\n\n\n<p>\u3053\u308c\u306f\u3001 \u5c02\u7528\u306e\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002 INI \u5f62\u5f0f\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<code>pytest<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>iniCopy \u30b3\u30fc\u30c9<strong>\u306e\u4f8b<\/strong><code>[pytest] addopts = --verbose markers = slow: marks tests as slow (deselect with '-m \"not slow\"')<\/code><\/li>\n\n\n\n<li><strong>\u4e3b\u306a\u30aa\u30d7\u30b7\u30e7\u30f3<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>addopts<\/code>: \u65e2\u5b9a\u306e\u30b3\u30de\u30f3\u30c9 \u30e9\u30a4\u30f3 \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>markers<\/code>:\u5206\u985e\u307e\u305f\u306f\u30e9\u30d9\u30eb\u30c6\u30b9\u30c8\u7528\u306e\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2. pyproject.toml<\/h4>\n\n\n\n<p>\u3053\u308c\u306f\u3001Python \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u7528\u306e\u3055\u307e\u3056\u307e\u306a\u30c4\u30fc\u30eb\u7528\u306e\u3088\u308a\u4e00\u822c\u7684\u306a\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u30b3\u30fc\u30c9\u4f8b<\/strong><code>[tool.pytest.ini_options] addopts = \"--verbose\" markers = [\"slow: marks tests as slow\"]<\/code><\/li>\n\n\n\n<li><strong>\u4e3b\u306a\u30aa\u30d7\u30b7\u30e7\u30f3<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u540c\u3058\u3002<code>pytest.ini<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3. \u30bb\u30c3\u30c8\u30a2\u30c3\u30d7.cfg<\/h4>\n\n\n\n<p>\u3053\u308c\u3082\u4e00\u822c\u7684\u306a\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u304c\u3001\u53e4\u3044\u3082\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>cfg\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<strong>\u306e\u4f8b<\/strong><code>[tool:pytest] addopts = --verbose markers = slow: marks tests as slow<\/code><\/li>\n\n\n\n<li><strong>\u4e3b\u306a\u30aa\u30d7\u30b7\u30e7\u30f3<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u540c\u3058\u3002<code>pytest.ini<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e00\u822c\u7684\u306a\u69cb\u6210\u30aa\u30d7\u30b7\u30e7\u30f3<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>testpaths<\/code>: \u30c6\u30b9\u30c8\u691c\u7d22\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>python_files<\/code>: \u30c6\u30b9\u30c8 \u30d5\u30a1\u30a4\u30eb\u306e\u30e2\u30fc\u30c9\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>python_classes<\/code>: \u30c6\u30b9\u30c8 \u30af\u30e9\u30b9\u306e\u30e2\u30fc\u30c9\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>python_functions<\/code>: \u30c6\u30b9\u30c8\u6a5f\u80fd\u3092\u30c6\u30b9\u30c8\u3059\u308b\u30e2\u30fc\u30c9\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>xfail_strict<\/code>: \u5931\u6557\u304c\u4e88\u60f3\u3055\u308c\u308b\u30c6\u30b9\u30c8\u3092\u53b3\u5bc6\u306b\u51e6\u7406\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>junit_family<\/code>: JUnit \u30ec\u30dd\u30fc\u30c8\u306e\u5f62\u5f0f\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u8a73\u7d30\u8a2d\u5b9a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>filterwarnings<\/code>: \u8b66\u544a\u306e\u8868\u793a\u3092\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>log_format<\/code>: \u30ed\u30b0\u5f62\u5f0f\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>log_level<\/code>: \u30ed\u30b0\u30ec\u30d9\u30eb\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3055\u307e\u3056\u307e\u306a\u7a2e\u985e\u306e\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u306e\u4f7f\u7528\u65b9\u6cd5\u3068\u3001\u4f7f\u7528\u53ef\u80fd\u306a\u3055\u307e\u3056\u307e\u306a\u69cb\u6210\u30aa\u30d7\u30b7\u30e7\u30f3\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306f\u3001\u521d\u5fc3\u8005\u304c\u30c6\u30b9\u30c8\u74b0\u5883\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u65b9\u6cd5\u3092\u3088\u308a\u3088\u304f\u7406\u89e3\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002 \u3053\u308c\u304c\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059\u3002<code>pytest<\/code><code>pytest<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>pytest\u304c\u4e00\u822c\u7684\u306b\u4f7f\u7528\u3059\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u3068\u3001\u3069\u306eChatGPT\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u8b66\u544a-\u672a\u4f7f\u7528\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u95a2\u9023\u3057\u3066\u3044\u308b\u304b\u3092\u8a73\u7d30\u306b\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e00\u822c\u7684\u306b\u4f7f\u7528\u3055\u308c\u308bpytest\u30d7\u30e9\u30b0\u30a4\u30f3<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1. Pytest-Cov<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684<\/strong>: \u30b3\u30fc\u30c9 \u30ab\u30d0\u30ec\u30c3\u30b8\u3092\u6e2c\u5b9a\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:<\/strong>&nbsp;<code>pip install pytest-cov<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528\u3059\u308b<\/strong>:&nbsp;<code>pytest --cov=myproject<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2. pytest-xdist<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684<\/strong>: \u30c6\u30b9\u30c8\u3092\u4e26\u884c\u3057\u3066\u5b9f\u884c\u3057\u3001\u30c6\u30b9\u30c8\u901f\u5ea6\u3092\u5411\u4e0a\u3055\u305b\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:<\/strong>&nbsp;<code>pip install pytest-xdist<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528\u3059\u308b<\/strong>:&nbsp;<code>pytest -n 4<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3.\u30d4\u30c6\u30b9\u30c8\u30b8\u30e3\u30f3\u30b4<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684<\/strong>: Django \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30c6\u30b9\u30c8\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:<\/strong>&nbsp;<code>pip install pytest-django<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528<\/strong>: Django \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u76f4\u63a5\u4f7f\u7528\u3059\u308b&nbsp;<code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">4.\u30d1\u30a4\u30c6\u30b9\u30c8\u30e2\u30c3\u30af<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684<\/strong>: \u5358\u7d14\u306a\u30e2\u30c3\u30af \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:<\/strong>&nbsp;<code>pip install pytest-mock<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528<\/strong>:\u30c6\u30b9\u30c8\u6a5f\u80fd\u3067\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<code>mocker<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">5. pytest-html<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684<\/strong>: HTML \u5f62\u5f0f\u3067\u30c6\u30b9\u30c8 \u30ec\u30dd\u30fc\u30c8\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:<\/strong>&nbsp;<code>pip install pytest-html<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528\u3059\u308b<\/strong>:&nbsp;<code>pytest --html=report.html<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">6. pytest-bdd<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684<\/strong>: \u52d5\u4f5c\u99c6\u52d5\u958b\u767a (BDD) \u3092\u30b5\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:<\/strong>&nbsp;<code>pip install pytest-bdd<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528\u3059\u308b<\/strong>:\u30ac\u30fc\u30ad\u30f3\u8a00\u8a9e\u3067\u30c6\u30b9\u30c8\u3092\u66f8\u304f\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">7.\u30d4\u30c6\u30b9\u30c8\u30bb\u30ec\u30f3<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4f7f\u7528<\/strong>:\u30bb\u30ec\u30f3\u30c6\u30b9\u30c8\u7528\u3002<\/li>\n\n\n\n<li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:<\/strong>&nbsp;<code>pip install pytest-selenium<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528<\/strong>:\u30c6\u30b9\u30c8\u3067\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<code>selenium<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">8.\u30d1\u30a4\u30c6\u30b9\u30c8\u30d5\u30e9\u30b9\u30b3<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684<\/strong>: Flask \u30a2\u30d7\u30ea\u3092\u30c6\u30b9\u30c8\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:<\/strong>&nbsp;<code>pip install pytest-flask<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528<\/strong>:\u30d5\u30e9\u30b9\u30b3\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u76f4\u63a5\u4f7f\u7528\u3059\u308b&nbsp;<code>pytest<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">9. pytest-asyncio<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684<\/strong>: \u975e\u540c\u671f\u30b3\u30fc\u30c9\u3092\u30c6\u30b9\u30c8\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:<\/strong>&nbsp;<code>pip install pytest-asyncio<\/code><\/li>\n\n\n\n<li><strong>\u7528\u9014<\/strong>: \u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<code>@pytest.mark.asyncio<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">10. Pytest-\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684<\/strong>: \u30c6\u30b9\u30c8\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3092\u4f5c\u6210\u304a\u3088\u3073\u6bd4\u8f03\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:<\/strong>&nbsp;<code>pip install pytest-snapshots<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528<\/strong>:\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<code>snapshot<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u3064\u3044\u3066<code>snapshot-warn-unused<\/code><\/h3>\n\n\n\n<p>\u3053\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u30d7\u30e9\u30b0\u30a4\u30f3\u306b\u95a2\u9023\u3057\u3066\u3044\u307e\u3059\u3002 \u3053\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u7528\u3057\u3066\u30c6\u30b9\u30c8\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u3001\u672a\u4f7f\u7528\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u304c\u3042\u308b\u5834\u5408\u3001use\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306f\u30c6\u30b9\u30c8\u51fa\u529b\u306b\u8b66\u544a\u3092\u8868\u793a\u3057\u307e\u3059\u3002<code>pytest-snapshots<\/code><code>--snapshot-warn-unused<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:<\/strong>&nbsp;<code>pip install pytest-snapshots<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528\u3059\u308b<\/strong>:&nbsp;<code>pytest --snapshot-warn-unused<\/code><\/li>\n<\/ul>\n\n\n\n<p>\u3053\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306f\u3001\u4e0d\u8981\u306b\u306a\u3063\u305f\u30c6\u30b9\u30c8 \u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3092\u7279\u5b9a\u3057\u3066\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u3057\u3001\u30c6\u30b9\u30c8 \u30b9\u30a4\u30fc\u30c8\u3092\u6574\u7406\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u60c5\u5831\u304c\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059\u3002<code>pytest<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u30a8\u30e9\u30fc:\u8981\u4ef6\u3092\u6e80\u305f\u3059\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305fpytest\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8(\u30d0\u30fc\u30b8\u30e7\u30f3\u304b\u3089:\u306a\u3057)ChatGPT<\/p>\n\n\n\n<p>\u7533\u3057\u8a33\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u9593\u9055\u3048\u307e\u3057\u305f\u3002 \u5b9f\u969b\u306b\u5b58\u5728\u3059\u308b\u516c\u5f0f\u306epytest\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002 \u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u30c6\u30b9\u30c8\u3092\u884c\u3046\u5834\u5408\u306f\u3001(\u6700\u7d42\u7684\u306a &#8216;s&#8217;\u304c\u306a\u3044\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044)\u307e\u305f\u306f.<code>pytest-snapshots<\/code><code>pytest-snapshot<\/code><code>snapshottest<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. Pytest-\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684<\/strong>: \u30c6\u30b9\u30c8\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3092\u4f5c\u6210\u304a\u3088\u3073\u6bd4\u8f03\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:<\/strong>&nbsp;<code>pip install pytest-snapshot<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528<\/strong>:\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<code>snapshot<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2.\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u30c6\u30b9\u30c8<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684<\/strong>: \u7279\u306b Django \u306e\u30c6\u30b9\u30c8\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3092\u4f5c\u6210\u304a\u3088\u3073\u6bd4\u8f03\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb:<\/strong>&nbsp;<code>pip install snapshottest<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528<\/strong>:\u304b\u3089\u306d\u3058\u3063\u3066\u4f7f\u7528\u3057\u307e\u3059\u3002<code>snapshottest.TestCase<\/code><code>self.assertMatchSnapshot()<\/code><\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306f\u3001 \u306a\u3069\u306e\u7279\u5b9a\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u5bfe\u3057\u3066\u540c\u69d8\u306e\u6a5f\u80fd\u3092\u6301\u3064\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u7279\u5b9a\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u540d\u306f\u7570\u306a\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002 \u8a73\u7d30\u306b\u3064\u3044\u3066\u306f\u3001\u3053\u308c\u3089\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<code>snapshot-warn-unused<\/code><\/p>\n\n\n\n<p>\u524d\u306e\u30a8\u30e9\u30fc\u3067\u7533\u3057\u8a33\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u4eca\u56de\u306f\u60c5\u5831\u304c\u3088\u308a\u6b63\u78ba\u3067\u6709\u7528\u3067\u3042\u308b\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u30a4\u30f3\u30dd\u30fc\u30c8\u30a8\u30e9\u30fc: &#8216;\u30d5\u30e9\u30b9\u30b3&#8217;\u30c1\u30e3\u30c3\u30c8GPT \u304b\u3089\u540d\u524d &#8216;_request_ctx_stack&#8217; \u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3067\u304d\u307e\u305b\u3093<\/p>\n\n\n\n<p>\u3053\u306e\u30a8\u30e9\u30fc\u306f\u901a\u5e38\u3001Flask \u30d1\u30c3\u30b1\u30fc\u30b8\u304b\u3089\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3088\u3046\u3068\u3057\u305f\u3068\u304d\u306b\u767a\u751f\u3057\u307e\u3059\u3002 \u3053\u308c\u306f\u901a\u5e38\u3001Flask\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u30b3\u30fc\u30c9\u307e\u305f\u306f\u4f9d\u5b58\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u4e92\u63db\u6027\u304c\u306a\u3044\u3053\u3068\u304c\u539f\u56e0\u3067\u3059\u3002<code>_request_ctx_stack<\/code><\/p>\n\n\n\n<p>\u8003\u3048\u3089\u308c\u308b\u89e3\u6c7a\u7b56\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1.\u30d5\u30e9\u30b9\u30b3\u3092\u66f4\u65b0\u3057\u307e\u3059<\/h3>\n\n\n\n<p>Flask\u3092\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u306b\u66f4\u65b0\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<\/p>\n\n\n\n<p><code>pip install --upgrade Flask<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u4f9d\u5b58\u95a2\u4fc2\u3092\u78ba\u8a8d\u3059\u308b<\/h3>\n\n\n\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304c\u7279\u5b9a\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306e Flask \u306b\u4f9d\u5b58\u3057\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u307e\u305f\u306f\u30d5\u30a1\u30a4\u30eb\u3067\u6b63\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<code>requirements.txt<\/code><code>setup.py<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.\u30b3\u30fc\u30c9\u3092\u78ba\u8a8d\u3057\u307e\u3059<\/h3>\n\n\n\n<p>\u30b3\u30fc\u30c9\u304cFlask\u304b\u3089\u76f4\u63a5\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u306a\u3044\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3001\u3042\u306a\u305f\u306f\u4e00\u822c\u7684\u306b\u3053\u306e\u5185\u90e8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u3059\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<code>_request_ctx_stack<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4.\u4ed6\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u78ba\u8a8d\u3057\u307e\u3059<\/h3>\n\n\n\n<p>Flask \u306b\u4f9d\u5b58\u3059\u308b\u30b5\u30fc\u30c9\u30d1\u30fc\u30c6\u30a3\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u3053\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u554f\u984c\u306e\u539f\u56e0\u3067\u3042\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002 \u3053\u308c\u3089\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u66f4\u65b0\u3059\u308b\u304b\u3001Flask \u3068\u306e\u4e92\u63db\u6027\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u4eee\u60f3\u74b0\u5883<\/h3>\n\n\n\n<p>\u6b63\u3057\u3044 Python \u4eee\u60f3\u74b0\u5883\u3067\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002 \u5834\u5408\u306b\u3088\u3063\u3066\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u30ec\u30d9\u30eb\u306e Python \u74b0\u5883\u3068\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30ec\u30d9\u30eb\u306e\u4eee\u60f3\u74b0\u5883\u304c\u7af6\u5408\u3092\u5f15\u304d\u8d77\u3053\u3059\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6.\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7<\/h3>\n\n\n\n<p>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3068\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3057\u3066\u304b\u3089\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u518d\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<code>__pycache__<\/code><code>.pyc<\/code><\/p>\n\n\n\n<p>\u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<\/p>\n\n\n\n<p><code>find . -name \"*.pyc\" -exec rm -f {} \\; find . -name \"__pycache__\" -exec rm -rf {} \\;<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">7. \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u78ba\u8a8d\u3059\u308b<\/h3>\n\n\n\n<p>\u3053\u306e\u554f\u984c\u306b\u95a2\u3059\u308b\u5177\u4f53\u7684\u306a\u60c5\u5831\u306b\u3064\u3044\u3066\u306f\u3001Flask \u304a\u3088\u3073\u95a2\u9023\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u4e0a\u8a18\u306e\u89e3\u6c7a\u7b56\u306e\u3044\u305a\u308c\u3082\u554f\u984c\u3092\u89e3\u6c7a\u3057\u306a\u3044\u5834\u5408\u306f\u3001\u518d\u73fe\u53ef\u80fd\u306a\u6700\u5c0f\u9650\u306e\u554f\u984c\u3067\u30b3\u30fc\u30c9\u30b5\u30f3\u30d7\u30eb\u3092\u4f5c\u6210\u3057\u3001Flask\u306e\u554f\u984c\u30c8\u30e9\u30c3\u30ab\u30fc\u307e\u305f\u306f\u95a2\u9023\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u306b\u76f8\u8ac7\u3059\u308b\u3053\u3068\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u30c1\u30e3\u30c3\u30c8GPT\u306e\u57fa\u672c\u7684\u306a\u8003\u3048\u65b9\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u6559\u3048\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u57fa\u672c\u6982\u5ff5\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u4e3b\u8981\u306a\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u6a5f\u80fd\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30c6\u30b9\u30c8_\u30b1\u30fc\u30b9<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u306f\u3001\u30b7\u30b9\u30c6\u30e0 \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u307e\u305f\u306f\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2 \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u7279\u5b9a\u306e\u8981\u4ef6\u3092\u6e80\u305f\u3057\u3001\u6b63\u3057\u304f\u52d5\u4f5c\u3059\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u65ad\u3059\u308b\u4e00\u9023\u306e\u6761\u4ef6\u307e\u305f\u306f\u5909\u6570\u3067\u3059\u3002 pytest \u3067\u306f\u3001\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u306f\u901a\u5e38\u3001\u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u304c\u4ed8\u3044\u305f\u540d\u524d\u306e Python \u95a2\u6570\u3067\u3059\u3002<code>test_<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u69cb\u9020<\/h4>\n\n\n\n<p>\u57fa\u672c\u7684\u306a pytest \u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>def test_addition(): assert 1 + 1 == 2<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e3b\u8981\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c6\u30b9\u30c8<\/strong>\u95a2\u6570: \u3067\u59cb\u307e\u308b\u95a2\u6570\u3002<code>test_<\/code><\/li>\n\n\n\n<li><strong>\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3<\/strong>: \u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u30c6\u30b9\u30c8\u5bfe\u8c61\u306e\u30b3\u30fc\u30c9\u306e\u52d5\u4f5c\u3092\u691c\u8a3c\u3057\u307e\u3059\u3002<code>assert<\/code><\/li>\n\n\n\n<li><strong>\u30d5\u30a3\u30af\u30b9\u30c1\u30e3<\/strong>:\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u30d7\u30ea\u30bb\u30c3\u30c8\u307e\u305f\u306f\u69cb\u6210\u3002<\/li>\n\n\n\n<li><strong>\u30de\u30fc\u30ab\u30fc<\/strong>: \u30c6\u30b9\u30c8\u3092\u5206\u985e\u307e\u305f\u306f\u9078\u629e\u7684\u306b\u5b9f\u884c\u3059\u308b\u305f\u3081\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u30bf\u30b0\u3002<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u65ad\u8a00<\/h4>\n\n\n\n<p>\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u306f\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u4e2d\u6838\u3067\u3059\u3002 \u3053\u308c\u3089\u306f\u3001\u30c6\u30b9\u30c8\u5bfe\u8c61\u306e\u30b3\u30fc\u30c9\u304c\u671f\u5f85\u3055\u308c\u308b\u7d50\u679c\u3092\u8fd4\u3059\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>def test_subtraction(): assert 5 - 3 == 2<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u8abf\u5ea6<\/h4>\n\n\n\n<p>\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306f\u3001\u30c6\u30b9\u30c8\u74b0\u5883\u307e\u305f\u306f\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002 \u305f\u3068\u3048\u3070\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3057\u3066\u3053\u306e\u63a5\u7d9a\u3092\u4f5c\u6210\u304a\u3088\u3073\u7834\u68c4\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>@pytest.fixture def database_connection(): conn = create_connection() yield conn conn.close() def test_database_query(database_connection): assert database_connection.query(\"SELECT 1\") == 1<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30de\u30fc\u30ab\u30fc<\/h4>\n\n\n\n<p>\u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u306b\u30e1\u30bf\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3057\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u30b3\u30de\u30f3\u30c9 \u30e9\u30a4\u30f3 \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>@pytest.mark.slow def test_large_computation(): assert compute_large_value() == \"expected_value\"<\/code><\/p>\n\n\n\n<p>\u4f4e\u901f\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u306b\u306f:<\/p>\n\n\n\n<p>\u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<\/p>\n\n\n\n<p><code>pytest -m slow<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc<\/h4>\n\n\n\n<p>\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u5316\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u8907\u6570\u306e\u30c7\u30fc\u30bf \u30bb\u30c3\u30c8\u3067\u540c\u3058\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u3092\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>@pytest.mark.parametrize(\"input,expected\", [(5, 25), (2, 4), (3, 9)]) def test_squares(input, expected): assert input ** 2 == expected<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u5b9a\u7fa9\u3001\u69cb\u9020\u3001\u4e3b\u8981\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3001PyTest\u3067\u306e\u5b9f\u88c5\u65b9\u6cd5\u306a\u3069\u3001\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u5305\u62ec\u7684\u304b\u3064\u8a73\u7d30\u306a\u8aac\u660e\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u521d\u5fc3\u8005\u304c\u6700\u3082\u56f0\u96e3\u306a\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3053\u308c\u304c\u3042\u306a\u305f\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306b\u5f79\u7acb\u3064\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u30c6\u30b9\u30c8\u30d5\u30a3\u30af\u30b9\u30c1\u30e3(ChatGPT)\u306e\u57fa\u672c\u7684\u306a\u6982\u5ff5\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u30c6\u30b9\u30c8\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u57fa\u672c\u6982\u5ff5\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u306a\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u6a5f\u80fd\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30c6\u30b9\u30c8\u30d5\u30a3\u30af\u30b9\u30c1\u30e3(\u30d5\u30a3\u30af\u30b9\u30c1\u30e3)<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>pytest\u3067\u306f\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3057\u3066\u3001\u95a2\u6570\u306e\u30c6\u30b9\u30c8\u306b\u5fc5\u8981\u306a\u4e8b\u524d\u8a2d\u5b9a\u3055\u308c\u305f\u6761\u4ef6\u307e\u305f\u306f\u74b0\u5883\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002 \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u306e\u4f5c\u6210\u3001\u5909\u6570\u306e\u521d\u671f\u5316\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u8a2d\u5b9a\u3001\u307e\u305f\u306f\u305d\u306e\u4ed6\u306e\u5fc5\u8981\u306a\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u307e\u305f\u306f\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u64cd\u4f5c\u306e\u5b9f\u884c\u306b\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u4f5c\u6210<\/h4>\n\n\n\n<p>\u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002 \u3053\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u95a2\u6570\u306f\u3001\u5fc5\u8981\u306a\u30ea\u30bd\u30fc\u30b9\u3092\u8fd4\u3057\u307e\u3059\u3002<code>@pytest.fixture<\/code><\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>import pytest @pytest.fixture def example_data(): return {\"key\": \"value\"}<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3059\u308b<\/h4>\n\n\n\n<p>\u30c6\u30b9\u30c8\u95a2\u6570\u3067\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3059\u308b\u306b\u306f\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u95a2\u6570\u540d\u3092\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066\u30c6\u30b9\u30c8\u95a2\u6570\u306b\u6e21\u3059\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>def test_example(example_data): assert example_data[\"key\"] == \"value\"<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u7bc4\u56f2<\/h4>\n\n\n\n<p>\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3092\u5236\u5fa1\u3067\u304d\u307e\u3059\u3002<code>scope<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u95a2\u6570\u30ec\u30d9\u30eb(\u30c7\u30d5\u30a9\u30eb\u30c8):<\/strong>&nbsp;\u5404\u30c6\u30b9\u30c8\u95a2\u6570\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u518d\u5b9f\u884c\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30e2\u30b8\u30e5\u30fc\u30eb \u30ec\u30d9\u30eb<\/strong>: \u30e2\u30b8\u30e5\u30fc\u30eb\u5168\u4f53\u3067 1 \u56de\u3060\u3051\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30bb\u30c3\u30b7\u30e7\u30f3 \u30ec\u30d9\u30eb<\/strong>: \u30c6\u30b9\u30c8 \u30bb\u30c3\u30b7\u30e7\u30f3\u5168\u4f53\u3067 1 \u56de\u3060\u3051\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>@pytest.fixture(scope=\"module\") def example_data(): return {\"key\": \"value\"}<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3<\/h4>\n\n\n\n<p>\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u3067\u304d\u307e\u3059\u3002<code>params<\/code><\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>@pytest.fixture(params=[1, 2, 3]) def example_data(request): return request.param<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u4f9d\u5b58\u95a2\u4fc2<\/h4>\n\n\n\n<p>1\u3064\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u304c\u4ed6\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306b\u4f9d\u5b58\u3059\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>@pytest.fixture def dependent_fixture(example_data): return example_data[\"key\"].upper()<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u306b\u6b69\u7559\u307e\u308a\u3092\u4f7f\u7528\u3059\u308b<\/h4>\n\n\n\n<p>\u3053\u306e\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u5185\u306e\u30ea\u30bd\u30fc\u30b9\u3092\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u3067\u304d\u307e\u3059\u3002<code>yield<\/code><\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>@pytest.fixture def database_connection(): conn = create_connection() yield conn conn.close()<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u81ea\u52d5\u4f7f\u7528<\/h4>\n\n\n\n<p>\u30c6\u30b9\u30c8 \u30bb\u30c3\u30b7\u30e7\u30f3\u307e\u305f\u306f\u30e2\u30b8\u30e5\u30fc\u30eb\u5168\u4f53\u306b\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u81ea\u52d5\u7684\u306b\u9069\u7528\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<code>autouse=True<\/code><\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>@pytest.fixture(autouse=True) def setup_and_teardown(): # Setup code yield # Teardown code<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3092\u4f5c\u6210\u3001\u4f7f\u7528\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u3001\u304a\u3088\u3073\u7ba1\u7406\u3059\u308b\u65b9\u6cd5\u306a\u3069\u3001\u30c6\u30b9\u30c8\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u3059\u3079\u3066\u306e\u5074\u9762\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306f\u3001\u521d\u5fc3\u8005\u304cpytest\u3067\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3057\u3066\u3001\u3088\u308a\u5805\u7262\u3067\u4fdd\u5b88\u3057\u3084\u3059\u3044\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u4f5c\u6210\u3059\u308b\u65b9\u6cd5\u3092\u3088\u308a\u3088\u304f\u7406\u89e3\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>ChatGPT\u306e\u57fa\u790e\u3068\u306a\u308b\u6982\u5ff5\u306e\u4e3b\u5f35\u3092\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u57fa\u672c\u6982\u5ff5\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u4e3b\u8981\u306a\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u6a5f\u80fd\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u65ad\u8a00\uff08Assertions\uff09<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u6761\u4ef6\u304c\u771f\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u30c6\u30b9\u30c8\u3067\u4f7f\u7528\u3055\u308c\u308b\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3067\u3059\u3002 \u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u304c\u5931\u6557\u3057\u305f\u5834\u5408 (\u3064\u307e\u308a\u3001\u6761\u4ef6\u304c false \u306e\u5834\u5408)\u3001\u30c6\u30b9\u30c8\u306f\u5931\u6557\u3057\u3001\u30a8\u30e9\u30fc \u30ec\u30dd\u30fc\u30c8\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002 pytest \u3067\u306f\u3001Python \u306e\u7d44\u307f\u8fbc\u307f\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u4f7f\u7528\u3057\u3066\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<code>assert<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h4>\n\n\n\n<p>\u6700\u3082\u7c21\u5358\u306a\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u5f0f\u304c\u771f\u3067\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>def test_addition(): assert 1 + 1 == 2<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u5f0f<\/h4>\n\n\n\n<p>\u57fa\u672c\u7684\u306a\u7b49\u53f7\u30c1\u30a7\u30c3\u30af\u306b\u52a0\u3048\u3066\u3001\u4ed6\u306e\u6709\u52b9\u306a Python \u5f0f\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>def test_collection(): assert 1 in [1, 2, 3]<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u591a\u91cd\u65ad\u8a00<\/h4>\n\n\n\n<p>\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u306b\u306f\u8907\u6570\u306e\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u3092\u542b\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u3044\u305a\u308c\u304b\u306e\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u304c\u5931\u6557\u3059\u308b\u3068\u3001\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u306f\u5b9f\u884c\u3092\u505c\u6b62\u3059\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>def test_multiple_assertions(): assert 1 + 1 == 2 assert 2 + 2 == 4<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u4f8b\u5916<\/h4>\n\n\n\n<p>\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8 \u30de\u30cd\u30fc\u30b8\u30e3\u30fc\u3092\u4f7f\u7528\u3057\u3066\u3001\u4e88\u671f\u3055\u308c\u308b\u4f8b\u5916\u304c\u30b9\u30ed\u30fc\u3055\u308c\u305f\u304b\u3069\u3046\u304b\u3092\u30a2\u30b5\u30fc\u30c8\u3067\u304d\u307e\u3059\u3002<code>pytest.raises<\/code><\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>def test_exception(): with pytest.raises(ValueError): int(\"invalid\")<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u5931\u6557\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b<\/h4>\n\n\n\n<p>\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u306e\u30ab\u30b9\u30bf\u30e0\u5931\u6557\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002<code>assert<\/code><\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>def test_custom_message(): assert 1 + 1 == 3, \"Custom failure message: 1 + 1 should equal 2, not 3\"<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u8907\u96d1\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u6bd4\u8f03<\/h4>\n\n\n\n<p>\u30ea\u30b9\u30c8\u3084\u30c7\u30a3\u30af\u30b7\u30e7\u30ca\u30ea\u306a\u3069\u306e\u8907\u96d1\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6bd4\u8f03\u306e\u5834\u5408\u3001pytest \u306f\u8a73\u7d30\u306a\u6bd4\u8f03\u51fa\u529b\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>def test_list(): assert [1, 2, 3] == [1, 2, 4]<\/code><\/p>\n\n\n\n<p>\u3053\u308c\u306b\u3088\u308a\u3001\u30ea\u30b9\u30c8\u5185\u306e\u3069\u306e\u8981\u7d20\u304c\u4e00\u81f4\u3057\u306a\u3044\u304b\u3092\u793a\u3059\u8a73\u7d30\u306a\u6bd4\u8f03\u51fa\u529b\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u306e\u6bd4\u8f03<\/h4>\n\n\n\n<p>\u6d6e\u52d5\u5c0f\u6570\u70b9\u7cbe\u5ea6\u306e\u554f\u984c\u304c\u3042\u308b\u305f\u3081\u3001\u6bd4\u8f03\u306b\u4f7f\u7528\u3059\u308b\u3053\u3068\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\u3002<code>pytest.approx<\/code><\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>def test_float(): assert 0.1 + 0.2 == pytest.approx(0.3)<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u306e\u5b9a\u7fa9\u3001\u4f7f\u7528\u6cd5\u3001pytest\u3067\u3088\u308a\u8907\u96d1\u306a\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u65b9\u6cd5\u306a\u3069\u3001\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u306e\u3055\u307e\u3056\u307e\u306a\u5074\u9762\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306f\u3001\u521d\u5fc3\u8005\u304c\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u30b3\u30fc\u30c9\u306e\u6b63\u78ba\u6027\u3068\u5805\u7262\u6027\u3092\u691c\u8a3c\u3059\u308b\u65b9\u6cd5\u3092\u3088\u308a\u3088\u304f\u7406\u89e3\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u304c\u30d5\u30a3\u30af\u30b9\u30c1\u30e3ChatGPT\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u3082\u306e\u3092\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3068\u306f\u300d\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u4f7f\u7528\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u7d39\u4ecb\u3068\u3057\u3066\u3001\u307e\u305f\u306f\u57fa\u790e\u3068\u306a\u308b\u6982\u5ff5\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u5f79\u7acb\u3061\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3068\u306f\u4f55\u3067\u3059\u304b?<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u30c6\u30b9\u30c8\u3067\u306f\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306f\u5b89\u5b9a\u3057\u305f\u30c6\u30b9\u30c8\u74b0\u5883\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u308b\u30e1\u30ab\u30cb\u30ba\u30e0\u3067\u3059\u3002 \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u306e\u521d\u671f\u5316\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u69cb\u6210\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8 \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u4f5c\u6210\u3001\u307e\u305f\u306f\u305d\u306e\u4ed6\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u307e\u305f\u306f\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7 \u30bf\u30b9\u30af\u306e\u5b9f\u884c\u306b\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002 pytest\u3067\u306f\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306f\u8907\u6570\u306e\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u307e\u305f\u306f\u30c6\u30b9\u30c8\u30e2\u30b8\u30e5\u30fc\u30eb\u9593\u3067\u5171\u6709\u3067\u304d\u308b\u518d\u5229\u7528\u53ef\u80fd\u306a\u30c6\u30b9\u30c8\u30ea\u30bd\u30fc\u30b9\u3067\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u306a\u305c\u5099\u54c1\u304c\u5fc5\u8981\u306a\u306e\u3067\u3059\u304b<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b3\u30fc\u30c9\u306e\u518d\u5229\u7528<\/strong>: \u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u8907\u6570\u306e\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u3067\u540c\u3058\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7 \u30b3\u30fc\u30c9\u3068\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7 \u30b3\u30fc\u30c9\u3092\u7e70\u308a\u8fd4\u3059\u3053\u3068\u3092\u56de\u907f\u3067\u304d\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30c7\u30ab\u30c3\u30d7\u30ea\u30f3\u30b0<\/strong>:\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u30c6\u30b9\u30c8\u30ed\u30b8\u30c3\u30af\u3092\u30c6\u30b9\u30c8\u74b0\u5883\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3068\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u304b\u3089\u5206\u96e2\u3067\u304d\u308b\u305f\u3081\u3001\u30c6\u30b9\u30c8\u306e\u4fdd\u5b88\u304c\u5bb9\u6613\u306b\u306a\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u67d4\u8edf\u6027<\/strong>:\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3059\u308b\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306b\u5f71\u97ff\u3092\u4e0e\u3048\u308b\u3053\u3068\u306a\u304f\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u5b9f\u88c5\u3092\u7c21\u5358\u306b\u5909\u66f4\u3067\u304d\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u30d1\u30e9\u30e1\u30fc\u30bf\u5316:\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092<strong>\u30d1\u30e9\u30e1\u30fc\u30bf\u5316<\/strong>\u3067\u304d\u308b\u305f\u3081\u3001\u540c\u3058\u30c6\u30b9\u30c8\u30ed\u30b8\u30c3\u30af\u3092\u7570\u306a\u308b\u6761\u4ef6\u4e0b\u3067\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u4ed5\u7d44\u307f<\/h4>\n\n\n\n<p>pytest\u3067\u306f\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306f\u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u5b9a\u7fa9\u3055\u308c\u305f\u901a\u5e38\u306ePython\u95a2\u6570\u3067\u3059\u3002 \u3053\u308c\u3089\u306e\u95a2\u6570\u306f\u3001\u30c6\u30b9\u30c8\u3067\u4f7f\u7528\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u30ea\u30bd\u30fc\u30b9\u3092\u8fd4\u3057\u307e\u3059\u3002<code>@pytest.fixture<\/code><\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>import pytest @pytest.fixture def example_data(): return {\"key\": \"value\"}<\/code><\/p>\n\n\n\n<p>\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u304c\u5b9a\u7fa9\u3055\u308c\u305f\u3089\u3001\u305d\u308c\u3092\u5f15\u6570\u3068\u3057\u3066\u30c6\u30b9\u30c8\u95a2\u6570\u306b\u6e21\u3059\u3053\u3068\u304c\u3067\u304d\u3001pytest\u306f\u81ea\u52d5\u7684\u306b\u305d\u306e\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3092\u51e6\u7406\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>def test_example(example_data): assert example_data[\"key\"] == \"value\"<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3068\u7bc4\u56f2<\/h4>\n\n\n\n<p>\u30af\u30e9\u30f3\u30d7\u306b\u306f\u3055\u307e\u3056\u307e\u306a\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3068\u30b9\u30b3\u30fc\u30d7\u304c\u3042\u308a\u3001\u95a2\u6570\u30ec\u30d9\u30eb (\u30c6\u30b9\u30c8\u95a2\u6570\u3054\u3068\u306b 1 \u3064\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9)\u3001\u30e2\u30b8\u30e5\u30fc\u30eb \u30ec\u30d9\u30eb (\u30e2\u30b8\u30e5\u30fc\u30eb\u3054\u3068\u306b 1 \u3064\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9)\u3001\u307e\u305f\u306f\u30bb\u30c3\u30b7\u30e7\u30f3 \u30ec\u30d9\u30eb (\u30c6\u30b9\u30c8 \u30bb\u30c3\u30b7\u30e7\u30f3\u5168\u4f53\u3067 1 \u3064\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9) \u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u69cb\u6210\u3068\u4f9d\u5b58\u95a2\u4fc2<\/h4>\n\n\n\n<p>\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306f\u4ed6\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306b\u4f9d\u5b58\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u305f\u3081\u3001\u30b3\u30fc\u30c9\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u5316\u3068\u518d\u5229\u7528\u6027\u3092\u7dad\u6301\u3057\u306a\u304c\u3089\u3001\u8907\u96d1\u306a\u30c6\u30b9\u30c8\u74b0\u5883\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3068\u306f\u4f55\u304b\u3001\u306a\u305c\u5fc5\u8981\u306a\u306e\u304b\u3001pytest\u3067\u3069\u306e\u3088\u3046\u306b\u6a5f\u80fd\u3059\u308b\u306e\u304b\u306b\u3064\u3044\u3066\u3001\u5305\u62ec\u7684\u304b\u3064\u8a73\u7d30\u306b\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u521d\u5fc3\u8005\u304cPyTest\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3057\u3066\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3057\u3066\u30d5\u30a3\u30af\u30b9\u30c1\u30e3ChatGPT\u3092\u4f5c\u6210\u3057\u3066\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u3092\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u4f5c\u6210\u65b9\u6cd5\u3068\u4f7f\u7528\u65b9\u6cd5\u300d\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u4f7f\u7528\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u30b3\u30a2\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u4f5c\u6210\u65b9\u6cd5\u3068\u4f7f\u7528\u65b9\u6cd5<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u4f5c\u6210<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u95a2\u6570<strong>\u3092\u5b9a\u7fa9\u3059\u308b<\/strong>: \u30c6\u30b9\u30c8\u3067\u4f7f\u7528\u3059\u308b\u30ea\u30bd\u30fc\u30b9\u307e\u305f\u306f\u8a2d\u5b9a\u3092\u8fd4\u3059\u901a\u5e38\u306e Python \u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u30c7\u30b3\u30ec\u30fc\u30bf\u306e\u8ffd\u52a0:&nbsp;<strong>\u30c7\u30b3\u30ec\u30fc\u30bf<\/strong>\u3092\u4f7f\u7528\u3057\u3066\u3001\u3053\u306e\u95a2\u6570\u3092\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3068\u3057\u3066\u30de\u30fc\u30af\u3057\u307e\u3059\u3002<code>@pytest.fixture<\/code><\/li>\n\n\n\n<li>\u30ea\u30bd\u30fc\u30b9<strong>\u3092\u8fd4\u3059<\/strong>: \u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u95a2\u6570\u5185\u3067\u3001\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u4f7f\u7528\u3057\u3066\u5fc5\u8981\u306a\u30ea\u30bd\u30fc\u30b9\u3092\u8fd4\u3057\u307e\u3059\u3002<code>return<\/code><\/li>\n<\/ol>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code># \u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5939\u5177 import pytest @pytest.fixture def example_data(): return {\"key\": \"value\"}<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3059\u308b<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066<\/strong>: \u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u95a2\u6570\u306e\u540d\u524d\u3092\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066\u30c6\u30b9\u30c8\u95a2\u6570\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30ea\u30bd\u30fc\u30b9\u3078\u306e\u30a2\u30af\u30bb\u30b9<\/strong>:\u30c6\u30b9\u30c8\u95a2\u6570\u5185\u3067\u306f\u3001\u3053\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u901a\u5e38\u306ePython\u5909\u6570\u306e\u3088\u3046\u306b\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code># \u4f7f\u7528\u5939\u5177 def test_example(example_data): assert example_data[\"key\"] == \"value\"<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u7bc4\u56f2<\/h4>\n\n\n\n<p>\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u30b9\u30b3\u30fc\u30d7\u3092\u5b9a\u7fa9\u3067\u304d\u307e\u3059\u3002<code>scope<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u95a2\u6570\u30ec\u30d9\u30eb(\u30c7\u30d5\u30a9\u30eb\u30c8):<\/strong>&nbsp;\u5404\u30c6\u30b9\u30c8\u95a2\u6570\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u518d\u5b9f\u884c\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30e2\u30b8\u30e5\u30fc\u30eb \u30ec\u30d9\u30eb<\/strong>: \u30e2\u30b8\u30e5\u30fc\u30eb\u5168\u4f53\u3067 1 \u56de\u3060\u3051\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30bb\u30c3\u30b7\u30e7\u30f3 \u30ec\u30d9\u30eb<\/strong>: \u30c6\u30b9\u30c8 \u30bb\u30c3\u30b7\u30e7\u30f3\u5168\u4f53\u3067 1 \u56de\u3060\u3051\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code># \u8bbe\u7f6e\u5939\u5177\u8303\u56f4\u4e3a\u6a21\u5757\u7ea7\u522b @pytest.fixture(scope=\"module\") def example_data(): return {\"key\": \"value\"}<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u5316<\/h4>\n\n\n\n<p>\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<code>params<\/code><\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code># \u53c2\u6570\u5316\u5939\u5177 @pytest.fixture(params=[1, 2, 3]) def example_data(request): return request.param<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u4f9d\u5b58\u95a2\u4fc2<\/h4>\n\n\n\n<p>1\u3064\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u304c\u4ed6\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306b\u4f9d\u5b58\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001\u3088\u308a\u8907\u96d1\u306a\u30c6\u30b9\u30c8\u74b0\u5883\u3092\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code># \u5939\u5177\u4f9d\u8d56 @pytest.fixture def more_data(example_data): example_data[\"more_key\"] = \"more_value\" return example_data<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u6e05\u7406\u8d44\u6e90<\/h4>\n\n\n\n<p>\u4f7f\u7528&nbsp;\u8bed\u53e5\u5728\u5939\u5177\u4e2d\u8fdb\u884c\u8d44\u6e90\u6e05\u7406\u3002<code>yield<\/code><\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code># \u4f7f\u7528 yield \u8fdb\u884c\u6e05\u7406 @pytest.fixture def database_connection(): conn = create_connection() yield conn conn.close()<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u8fd9\u4e2a\u5b50\u8282\u8be6\u7ec6\u5730\u89e3\u91ca\u4e86\u5982\u4f55\u521b\u5efa\u548c\u4f7f\u7528 pytest \u4e2d\u7684\u5939\u5177\uff0c\u5305\u62ec\u5982\u4f55\u5b9a\u4e49\u3001\u8c03\u7528\u3001\u53c2\u6570\u5316\u548c\u7ba1\u7406\u5939\u5177\u7684\u751f\u547d\u5468\u671f\u3002\u8fd9\u5c06\u4e3a\u521d\u5b66\u8005\u63d0\u4f9b\u4e00\u4e2a\u660e\u786e\u548c\u5bb9\u6613\u9075\u5faa\u7684\u8def\u5f84\uff0c\u4ee5\u5f00\u59cb\u4ed6\u4eec\u5728 pytest \u4e2d\u4f7f\u7528\u5939\u5177\u7684\u5b66\u4e60\u4e4b\u65c5\u3002\u5e0c\u671b\u8fd9\u80fd\u5e2e\u52a9\u4f60\u5728\u521b\u5efa\u4f60\u7684 pytest \u6559\u7a0b\u65f6\u63d0\u4f9b\u6709\u4ef7\u503c\u7684\u4fe1\u606f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u8bf7\u8be6\u7ec6\u89e3\u91ca\u4f7f\u7528Fixtures\u7684Fixtures\u7684\u4f5c\u7528\u57dfChatGPT<\/p>\n\n\n\n<p>\u5f53\u7136\uff0c\u4ee5\u4e0b\u662f\u5bf9\u201dFixtures \u7684\u4f5c\u7528\u57df\uff08Scope\uff09\u201d\u8fd9\u4e00\u90e8\u5206\u7684\u8be6\u7ec6\u89e3\u91ca\u3002\u8fd9\u53ef\u4ee5\u4f5c\u4e3a\u4f60\u6559\u7a0b\u4e2d\u201d\u4f7f\u7528 Fixtures\u201d\u90e8\u5206\u7684\u4e00\u4e2a\u91cd\u8981\u5b50\u8282\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Fixtures \u7684\u4f5c\u7528\u57df\uff08Scope\uff09<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>pytest\u3067\u306f\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u30b9\u30b3\u30fc\u30d7\u306f\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3001\u3064\u307e\u308a\u4f5c\u6210\u304a\u3088\u3073\u7834\u68c4\u3055\u308c\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002 \u30b9\u30b3\u30fc\u30d7\u306f\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u518d\u5229\u7528\u3068\u30c6\u30b9\u30c8\u5b9f\u884c\u306e\u901f\u5ea6\u306b\u5f71\u97ff\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u7a2e\u985e<\/h4>\n\n\n\n<p>PyTest \u3067\u306f\u3001\u6b21\u306e\u7a2e\u985e\u306e\u30b9\u30b3\u30fc\u30d7\u304c\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u6a5f\u80fd\u30ec\u30d9\u30eb<code><\/code><\/strong>: \u65e2\u5b9a\u306e\u30b9\u30b3\u30fc\u30d7\u3002 \u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306b\u4f9d\u5b58\u3059\u308b\u30c6\u30b9\u30c8\u95a2\u6570\u3054\u3068\u306b\u3001\u65b0\u3057\u3044\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30e2\u30b8\u30e5\u30fc\u30eb\u30ec\u30d9\u30eb<code><\/code><\/strong>:Python\u30e2\u30b8\u30e5\u30fc\u30eb\u5168\u4f53(\u30d5\u30a1\u30a4\u30eb)\u5185\u3067\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306f\u4e00\u5ea6\u3060\u3051\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<code>.py<\/code><\/li>\n\n\n\n<li><strong>\u30af\u30e9\u30b9\u30ec\u30d9\u30eb<code><\/code><\/strong>: \u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306f\u30c6\u30b9\u30c8\u30af\u30e9\u30b9\u5168\u4f53\u3067\u4e00\u5ea6\u3060\u3051\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u30bb\u30c3\u30b7\u30e7\u30f3<strong>\u30ec\u30d9\u30eb<code><\/code><\/strong>:\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306f\u30c6\u30b9\u30c8\u30bb\u30c3\u30b7\u30e7\u30f3\u5168\u4f53(\u3064\u307e\u308a\u3001\u3059\u3079\u3066\u306e\u30c6\u30b9\u30c8)\u4e2d\u306b\u4e00\u5ea6\u3060\u3051\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u30b9\u30b3\u30fc\u30d7\u306e\u8a2d\u5b9a\u65b9\u6cd5<\/h4>\n\n\n\n<p>\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u4f7f\u7528\u3057\u3066\u3001\u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\u306e\u30b9\u30b3\u30fc\u30d7\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<code>scope<\/code><code>@pytest.fixture<\/code><\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code># \u8bbe\u7f6e\u6a21\u5757\u7ea7\u522b\u7684\u4f5c\u7528\u57df @pytest.fixture(scope=\"module\") def example_data(): return {\"key\": \"value\"}<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30b9\u30b3\u30fc\u30d7\u304c\u91cd\u8981\u306a\u7406\u7531<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9<\/strong>: \u30bb\u30c3\u30b7\u30e7\u30f3 \u30ec\u30d9\u30eb\u306a\u3069\u306e\u3088\u308a\u9ad8\u3044\u30ec\u30d9\u30eb\u306e\u30b9\u30b3\u30fc\u30d7\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u8a2d\u5b9a\u3068\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u306e\u6570\u304c\u6e1b\u308a\u3001\u30c6\u30b9\u30c8\u304c\u9ad8\u901f\u5316\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u5206\u96e2<\/strong>: \u95a2\u6570\u30ec\u30d9\u30eb\u306a\u3069\u306e\u4e0b\u4f4d\u30ec\u30d9\u30eb\u306e\u30b9\u30b3\u30fc\u30d7\u3067\u306f\u3001\u30c6\u30b9\u30c8\u306e\u5206\u96e2\u304c\u5411\u4e0a\u3057\u307e\u3059\u304c\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u4f4e\u4e0b\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30ea\u30bd\u30fc\u30b9\u7ba1\u7406<\/strong>: \u9069\u5207\u306a\u30b9\u30b3\u30fc\u30d7\u3092\u8a2d\u5b9a\u3059\u308b\u3068\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u3001\u30d5\u30a1\u30a4\u30eb\u3001\u307e\u305f\u306f\u305d\u306e\u4ed6\u306e\u30ea\u30bd\u30fc\u30b9\u3092\u3088\u308a\u52b9\u7387\u7684\u306b\u7ba1\u7406\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b46\u8a18<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u4f9d\u5b58\u95a2\u4fc2<\/strong>: \u9ad8\u30b9\u30b3\u30fc\u30d7\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u304c\u4f4e\u30b9\u30b3\u30fc\u30d7\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306b\u4f9d\u5b58\u3057\u3066\u3044\u308b\u5834\u5408\u3001\u4f4e\u30b9\u30b3\u30fc\u30d7\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306f\u3001\u9ad8\u30b9\u30b3\u30fc\u30d7\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u547c\u3073\u51fa\u3059\u305f\u3073\u306b\u518d\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7<\/strong>: \u30e2\u30b8\u30e5\u30fc\u30eb\u30ec\u30d9\u30eb\u304a\u3088\u3073\u30bb\u30c3\u30b7\u30e7\u30f3\u30ec\u30d9\u30eb\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u5834\u5408\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u95a2\u6570\u3067\u9069\u5207\u306a\u30ea\u30bd\u30fc\u30b9\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u3092\u78ba\u4fdd\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001pytest\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u30b9\u30b3\u30fc\u30d7\u306e\u3055\u307e\u3056\u307e\u306a\u5074\u9762\u306b\u3064\u3044\u3066\u3001\u305d\u308c\u3089\u304c\u4f55\u3067\u3042\u308b\u304b\u3001\u3069\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u304b\u3001\u306a\u305c\u305d\u308c\u3089\u304c\u91cd\u8981\u306a\u306e\u304b\u306a\u3069\u3001\u8a73\u7d30\u306b\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306f\u3001\u521d\u5fc3\u8005\u304c\u30b9\u30b3\u30fc\u30d7\u3092\u52b9\u679c\u7684\u306b\u4f7f\u7528\u3057\u3066\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u3092\u7ba1\u7406\u3059\u308b\u65b9\u6cd5\u3092\u3088\u308a\u3088\u304f\u7406\u89e3\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>ChatGPT\u306e\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30c6\u30b9\u30c8\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u30c6\u30b9\u30c8\u3068\u306f\u300d\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af \u30c6\u30b9\u30c8\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u7d39\u4ecb\u3068\u3057\u3066\u3001\u307e\u305f\u306f\u57fa\u790e\u3068\u306a\u308b\u6982\u5ff5\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u5f79\u7acb\u3061\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u5316\u30c6\u30b9\u30c8\u3068\u306f<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30c6\u30b9\u30c8\u306f\u3001\u7570\u306a\u308b\u5165\u529b\u30c7\u30fc\u30bf\u3067\u540c\u3058\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u3092\u4f53\u7cfb\u7684\u306b\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u308b\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u30c6\u30b9\u30c8\u624b\u6cd5\u3067\u3059\u3002 \u3053\u306e\u76ee\u7684\u306f\u3001\u3055\u307e\u3056\u307e\u306a\u6761\u4ef6\u4e0b\u3067\u30c6\u30b9\u30c8\u5bfe\u8c61\u306e\u30b3\u30fc\u30c9\u306e\u52d5\u4f5c\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u3067\u3059\u3002 pytest\u3067\u306f\u3001\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30c6\u30b9\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3001\u8907\u6570\u306e\u30d0\u30ea\u30a2\u30f3\u30c8\u3092\u542b\u3080\u5358\u4e00\u306e\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u3092\u540c\u6642\u306b\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u691c\u5b9a\u304c\u5fc5\u8981\u306a\u7406\u7531<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b3\u30fc\u30c9\u306e\u518d\u5229\u7528<\/strong>: \u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u5316\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u307b\u307c\u540c\u4e00\u306e\u8907\u6570\u306e\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u3092\u8a18\u8ff0\u3059\u308b\u5fc5\u8981\u304c\u306a\u304f\u306a\u308b\u305f\u3081\u3001\u30b3\u30fc\u30c9\u306e\u91cd\u8907\u3092\u6e1b\u3089\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u5305\u62ec\u6027<\/strong>: \u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u5316\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u8907\u6570\u306e\u30c7\u30fc\u30bf \u30bb\u30c3\u30c8\u3092\u4f7f\u7528\u3057\u3066\u6a5f\u80fd\u3092\u5fb9\u5e95\u7684\u306b\u30c6\u30b9\u30c8\u3057\u3001\u3055\u307e\u3056\u307e\u306a\u6761\u4ef6\u4e0b\u3067\u9069\u5207\u306b\u6a5f\u80fd\u3059\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u7c21\u5358\u306a\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9<\/strong>: \u30c6\u30b9\u30c8 \u30ed\u30b8\u30c3\u30af\u3092\u5909\u66f4\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u8907\u6570\u306e\u500b\u5225\u306e\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u3092\u66f4\u65b0\u3059\u308b\u4ee3\u308f\u308a\u306b\u30011 \u304b\u6240\u3067\u5909\u66f4\u3092\u52a0\u3048\u308b\u3060\u3051\u3067\u6e08\u307f\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30ab\u30d0\u30ec\u30c3\u30b8\u306e\u5411\u4e0a<\/strong>: \u3055\u307e\u3056\u307e\u306a\u30c6\u30b9\u30c8 \u30c7\u30fc\u30bf\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u30b3\u30fc\u30c9\u3092\u3088\u308a\u5305\u62ec\u7684\u306b\u30ab\u30d0\u30fc\u3057\u3001\u30c6\u30b9\u30c8\u306e\u54c1\u8cea\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u305d\u308c\u3092\u9054\u6210\u3059\u308b\u65b9\u6cd5<\/h4>\n\n\n\n<p>pytest \u3067\u306f\u3001\u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af \u30c6\u30b9\u30c8\u3092\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002<code>@pytest.mark.parametrize<\/code><\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>import pytest @pytest.mark.parametrize(\"input,expected\", [(5, 25), (2, 4), (3, 9)]) def test_squares(input, expected): assert input ** 2 == expected<\/code><\/p>\n\n\n\n<p>\u3053\u3053\u3067\u3001 \u3068 \u306f\u30c6\u30b9\u30c8\u95a2\u6570\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3001 \u306f\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u5024\u3067\u3042\u308b\u3002 \u3053\u306e\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u306f\u3001\u7570\u306a\u308b\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc \u30bb\u30c3\u30c8\u3092\u4f7f\u7528\u3057\u3066 3 \u56de\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<code>input<\/code><code>expected<\/code><code>test_squares<\/code><code>[(5, 25), (2, 4), (3, 9)]<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3<\/h4>\n\n\n\n<p>\u30c6\u30b9\u30c8\u95a2\u6570\u306b\u52a0\u3048\u3066\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u3057\u3066\u3001\u7570\u306a\u308b\u30c6\u30b9\u30c8\u74b0\u5883\u3067\u540c\u3058\u30c6\u30b9\u30c8\u30ed\u30b8\u30c3\u30af\u3092\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>@pytest.fixture(params=[1, 2, 3]) def example_data(request): return request.param<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u3055\u308c\u305f\u30c6\u30b9\u30c8\u3068\u306f\u4f55\u304b\u3001\u306a\u305c\u305d\u308c\u304c\u5fc5\u8981\u306a\u306e\u304b\u3001pytest\u3067\u5b9f\u88c5\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u5305\u62ec\u7684\u304b\u3064\u8a73\u7d30\u306b\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u521d\u5fc3\u8005\u304cPytest\u306e\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30c6\u30b9\u30c8\u3067\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30c6\u30b9\u30c8ChatGPT\u306e\u5b9f\u884c\u65b9\u6cd5\u3092\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30c6\u30b9\u30c8\u306e\u65b9\u6cd5\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af \u30c6\u30b9\u30c8\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u30b3\u30a2 \u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u691c\u5b9a\u306e\u5b9f\u884c\u65b9\u6cd5<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u4f7f\u7528\u3059\u308b<code>@pytest.mark.parametrize<\/code><\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>pytest \u306e\u30a4\u30f3\u30dd\u30fc\u30c8: \u307e\u305a\u3001<strong>pytest<\/strong>&nbsp;\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u305f\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002 pythonCopy code<code>import pytest<\/code><\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u95a2\u6570\u3092\u5b9a\u7fa9\u3059\u308b:&nbsp;<strong>\u30c6\u30b9\u30c8\u95a2\u6570<\/strong>\u3092\u4f5c\u6210\u3057\u3001\u305d\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002 \u3053\u308c\u3089\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306f\u3001\u30c6\u30b9\u30c8 \u30c7\u30fc\u30bf\u3092\u53d7\u4fe1\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002 pythonCopy code<code>def test_multiply(a, b, expected): ...<\/code><\/li>\n\n\n\n<li>\u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b:&nbsp;<strong>\u30c7\u30b3\u30ec\u30fc\u30bf<\/strong>\u3092\u4f7f\u7528\u3057\u3066\u3001\u30c6\u30b9\u30c8\u95a2\u6570\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u540d\u3092\u8868\u3059\u6587\u5b57\u5217\u3068\u5024\u306e\u30ea\u30b9\u30c8\u306e 2 \u3064\u306e\u4e3b\u8981\u306a\u5f15\u6570\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002 pythonCopy code \u3053\u3053\u3067\u306f\u3001\u5404\u30bf\u30d7\u30eb\u304c\u4e00\u9023\u306e\u30c6\u30b9\u30c8 \u30c7\u30fc\u30bf\u3092\u8868\u3057\u307e\u3059\u3002<code>@pytest.mark.parametrize<\/code><code>@pytest.mark.parametrize(\"a, b, expected\", [(1, 2, 2), (2, 3, 6), (3, 5, 15)]) def test_multiply(a, b, expected): assert a * b == expected&nbsp;<\/code><code>(a, b, expected)<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u8907\u6570\u306e\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u3092\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u5316\u3059\u308b<\/h4>\n\n\n\n<p>\u30e2\u30b8\u30e5\u30fc\u30eb\u307e\u305f\u306f\u30af\u30e9\u30b9\u5185\u306e\u8907\u6570\u306e\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u3092\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u5316\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>@pytest.mark.parametrize(\"a, b, expected\", [(1, 2, 2), (2, 3, 6)]) class TestMultiply: def test_multiply_positive(self, a, b, expected): assert a * b == expected def test_multiply_properties(self, a, b, expected): assert a * b == b * a<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u5b9a\u7fa9<\/strong>: \u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u4f7f\u7528\u3059\u308b\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002 pythonCopy code<code>@pytest.fixture<\/code><code>@pytest.fixture def example_data(): return 42<\/code><\/li>\n\n\n\n<li><strong>\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3<\/strong>: \u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u5b9a\u7fa9\u3067\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 pythonCopy code<code>params<\/code><code>@pytest.fixture(params=[1, 2, 3]) def example_data(request): return request.param<\/code><\/li>\n\n\n\n<li>\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3059\u308b: \u30c6\u30b9\u30c8\u95a2\u6570\u3067\u306f\u3001\u901a\u5e38\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3067\u3042\u308b\u304b\u306e\u3088\u3046\u306b<strong>\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3<\/strong>\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 pythonCopy code<code>def test_example(example_data): assert example_data in [1, 2, 3]<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u7d50\u5408<\/h4>\n\n\n\n<p>\u8907\u6570\u306e\u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u3001\u8907\u6570\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<code>@pytest.mark.parametrize<\/code><\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>@pytest.mark.parametrize(\"a\", [1, 2]) @pytest.mark.parametrize(\"b\", [3, 4]) def test_combination(a, b): assert a &lt; b<\/code><\/p>\n\n\n\n<p>\u3053\u308c\u306b\u3088\u308a\u3001\u6b21\u306e 4 \u3064\u306e\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<code>(1, 3), (1, 4), (2, 3), (2, 4)<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30c7\u30b3\u30ec\u30fc\u30bf\u306e\u4f7f\u7528\u3001\u8907\u6570\u306e\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u3001\u8907\u6570\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u3068\u7d44\u307f\u5408\u308f\u305b\u306a\u3069\u3001\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u521d\u5fc3\u8005\u304cPytest\u306e\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30c6\u30b9\u30c8\u3067\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<code>@pytest.mark.parametrize<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30c6\u30b9\u30c8\u306e\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u30c1\u30e3\u30c3\u30c8GPT\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af \u30c6\u30b9\u30c8\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u5c02\u7528\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>pytest\u3067\u306f\u3001\u30c6\u30b9\u30c8\u95a2\u6570\u3092\u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u3059\u308b\u3053\u3068\u306b\u52a0\u3048\u3066\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002 \u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u7570\u306a\u308b\u30c6\u30b9\u30c8\u74b0\u5883\u307e\u305f\u306f\u6761\u4ef6\u3067\u540c\u3058\u30c6\u30b9\u30c8\u30ed\u30b8\u30c3\u30af\u3092\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u5b9f\u88c5\u65b9\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u5b9a\u7fa9<\/strong>: \u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002 pythonCopy code<code>@pytest.fixture<\/code><code>@pytest.fixture def example_data(): return {\"key\": \"value\"}<\/code><\/li>\n\n\n\n<li><strong>\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u8ffd\u52a0<\/strong>: \u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u5b9a\u7fa9\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u3001\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306e\u30bb\u30c3\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 pythonCopy \u30b3\u30fc\u30c9\u3067\u306f\u3001\u3053\u3053\u3067 3 \u3064\u306e\u7570\u306a\u308b\u30c6\u30b9\u30c8 \u30c7\u30fc\u30bf \u30bb\u30c3\u30c8\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<code>params<\/code><code>@pytest.fixture(params=[1, 2, 3]) def example_data(request): return request.param&nbsp;<\/code><code>params=[1, 2, 3]<\/code><\/li>\n\n\n\n<li><strong>\u30a2\u30af\u30bb\u30b9<\/strong>&nbsp;\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc: \u73fe\u5728\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u5024\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<code>request.param<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u4f7f\u7528\u65b9\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c6\u30b9\u30c8\u95a2\u6570\u3067\u4f7f\u7528<\/strong>: \u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u3055\u308c\u305f\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u540d\u524d\u3092\u30c6\u30b9\u30c8\u95a2\u6570\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066\u4f7f\u7528\u3057\u307e\u3059\u3002 pythonCopy code<code>def test_example(example_data): assert example_data in [1, 2, 3]<\/code><\/li>\n\n\n\n<li><strong>\u7d44\u307f\u5408\u308f\u305b<\/strong>: \u30c6\u30b9\u30c8\u95a2\u6570\u3067\u8907\u6570\u306e\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002 pythonCopy code<code>@pytest.fixture(params=[4, 5, 6]) def more_data(request): return request.param def test_combination(example_data, more_data): assert example_data + more_data in [5, 6, 7, 6, 7, 8, 7, 8, 9]<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b46\u8a18<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b9\u30b3\u30fc\u30d7<\/strong>: \u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u3055\u308c\u305f\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u30b9\u30b3\u30fc\u30d7\u306f\u3001\u30c6\u30b9\u30c8\u95a2\u6570\u307e\u305f\u306f\u305d\u308c\u3089\u3092\u4f7f\u7528\u3059\u308b\u4ed6\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u30b9\u30b3\u30fc\u30d7\u3068\u4e92\u63db\u6027\u304c\u3042\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u4f9d\u5b58\u95a2\u4fc2<\/strong>: \u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306f\u4ed6\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306b\u4f9d\u5b58\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u30b9\u30b3\u30fc\u30d7\u3068\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u7d44\u307f\u5408\u308f\u305b\u306b\u6ce8\u610f\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u30ea\u30bd\u30fc\u30b9\u306e\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7: \u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3067\u30ea\u30bd\u30fc\u30b9\u306e\u5272\u308a\u5f53\u3066\u3068<strong>\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7<\/strong>\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\u3001\u3053\u308c\u3089\u306e\u64cd\u4f5c\u304c\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u5316\u3068\u4e92\u63db\u6027\u304c\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u5b9a\u7fa9\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u8ffd\u52a0\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3001\u305d\u308c\u3089\u306e\u7d44\u307f\u5408\u308f\u305b\u306a\u3069\u3001PyTest\u3067\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u5b9f\u88c5\u3057\u3066\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u521d\u5fc3\u8005\u304cPytest\u306e\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3057\u3066\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>pytest.mark ChatGPT\u3092\u4f7f\u7528\u3057\u3066\u30de\u30fc\u30af\u3055\u308c\u305f\u30bf\u30b0\u3067\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u3092\u8a73\u7d30\u306b\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u4f7f\u7528\u6cd5\u306b\u3088\u308b\u30de\u30fc\u30ad\u30f3\u30b0\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30bf\u30b0\u3068\u30e9\u30d9\u30eb\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u30b3\u30a2 \u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<code>pytest.mark<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30de\u30fc\u30af\u306b\u4f7f\u7528<code>pytest.mark<\/code><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>pytest\u3067\u306f\u3001\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u306b\u30e1\u30bf\u30c7\u30fc\u30bf\u30bf\u30b0(\u307e\u305f\u306f\u30bf\u30b0)\u3092\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306e\u30e1\u30ab\u30cb\u30ba\u30e0\u3067\u3059\u3002 \u3053\u308c\u3089\u306e\u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u3001\u7279\u5b9a\u306e\u30c6\u30b9\u30c8 \u30a2\u30af\u30b7\u30e7\u30f3\u3092\u30d5\u30a3\u30eb\u30bf\u30fc\u51e6\u7406\u3001\u4e26\u3079\u66ff\u3048\u3001\u307e\u305f\u306f\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<code>pytest.mark<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30bf\u30b0\u3092\u8ffd\u52a0\u3059\u308b\u65b9\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5358\u4e00\u30de\u30fc\u30af\u30a2\u30c3\u30d7<\/strong>: \u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\u3092\u4f7f\u7528\u3057\u3066\u3001\u30c6\u30b9\u30c8\u95a2\u6570\u306b\u30bf\u30b0\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 pythonCopy code<code>@pytest.mark.MARK_NAME<\/code><code>@pytest.mark.slow def test_slow_function(): pass<\/code><\/li>\n\n\n\n<li><strong>\u8907\u6570\u306e<\/strong>\u30bf\u30b0: \u30c6\u30b9\u30c8\u95a2\u6570\u306b\u8907\u6570\u306e\u30bf\u30b0\u3092\u8ffd\u52a0\u3067\u304d\u307e\u3059\u3002 pythonCopy code<code>@pytest.mark.slow @pytest.mark.regression def test_slow_and_regression(): pass<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u30bf\u30b0\u306e\u4f7f\u7528\u65b9\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u7279\u5b9a\u306e\u30bf\u30b0\u3067<strong>\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b<\/strong>: \u7279\u5b9a\u306e\u30bf\u30b0\u3067\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 bashCopy \u30b3\u30fc\u30c9 \u3053\u308c\u306f\u3001\u30bf\u30b0\u3067\u30de\u30fc\u30af\u3055\u308c\u305f\u30c6\u30b9\u30c8\u306e\u307f\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<code>-m<\/code><code>pytest -m slow&nbsp;<\/code><code>@pytest.mark.slow<\/code><\/li>\n\n\n\n<li>\u7279\u5b9a\u306e\u30bf\u30b0\u3092\u6301\u3064<strong>\u30c6\u30b9\u30c8\u3092\u9664\u5916<\/strong>\u3059\u308b: \u7279\u5b9a\u306e\u30bf\u30b0\u3092\u6301\u3064\u30c6\u30b9\u30c8\u3092\u9664\u5916\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>-m \"not MARK_NAME\"<\/code><code>pytest -m \"not slow\"<\/code><\/li>\n\n\n\n<li>\u30bf\u30b0<strong>\u3092\u7d44\u307f\u5408\u308f\u305b\u308b<\/strong>: \u3001\u3001) \u306a\u3069\u306e\u8ad6\u7406\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3057\u3066\u3001\u8907\u6570\u306e\u30bf\u30b0\u3092\u7d50\u5408\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>and<\/code><code>or<\/code><code>not<\/code><code>pytest -m \"slow and regression\"<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u306e\u767b\u9332: pytest \u306e\u672a\u767b\u9332\u30bf\u30b0\u306e\u8b66\u544a\u3092\u56de\u907f\u3059\u308b\u305f\u3081\u306b\u3001\u307e\u305f\u306f\u30d5\u30a1\u30a4\u30eb\u306b<strong>\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3092\u767b\u9332\u3057<\/strong>\u307e\u3059\u3002 \u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b<code>pytest.ini<\/code><code>pyproject.toml<\/code><code># pytest.ini [pytest] markers = slow: marks tests as slow (deselect with '-m \"not slow\"')<\/code><\/li>\n\n\n\n<li>\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0<strong>\u3092\u4f7f\u7528\u3059\u308b<\/strong>: \u30b5\u30a4\u30f3\u30a2\u30c3\u30d7\u3059\u308b\u3068\u3001\u7d44\u307f\u8fbc\u307f\u30bf\u30b0\u3068\u540c\u3058\u3088\u3046\u306b\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002 pythonCopy code<code>@pytest.mark.slow def test_custom_marker(): pass<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u5316\u3055\u308c\u305f\u30de\u30fc\u30ab\u30fc<\/h4>\n\n\n\n<p>\u30bf\u30b0\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8ffd\u52a0\u3057\u3066\u3001\u3088\u308a\u8907\u96d1\u306a\u30c6\u30b9\u30c8\u30ed\u30b8\u30c3\u30af\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>pythonCopy code<\/p>\n\n\n\n<p><code>@pytest.mark.parametrize(\"input,expected\", [(3, 9), (4, 16)], ids=[\"3^2\", \"4^2\"]) def test_squares(input, expected): assert input ** 2 == expected<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u306e\u8ffd\u52a0\u3001\u4f7f\u7528\u3001\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u306a\u3069\u3001\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u306b pytest \u3092\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u521d\u5fc3\u8005\u304cpytest\u306e\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u3092\u4f7f\u7528\u3057\u3066\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<code>pytest.mark<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u30bf\u30b0ChatGPT\u4ed8\u304d\u306e\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u30ab\u30b9\u30bf\u30e0\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30bf\u30b0\u3068\u30e9\u30d9\u30eb\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u5c02\u7528\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u30c6\u30b9\u30c8\u306e\u30cb\u30fc\u30ba\u306b\u56fa\u6709\u306e\u30bf\u30b0\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002 \u3053\u308c\u3089\u306e\u30bf\u30b0\u306f\u3001\u7d44\u307f\u8fbc\u307f\u30bf\u30b0\u3068\u540c\u69d8\u306b\u3001\u7279\u5b9a\u306e\u30c6\u30b9\u30c8\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u4e26\u3079\u66ff\u3048\u3001\u30d5\u30a3\u30eb\u30bf\u30fc\u51e6\u7406\u3001\u307e\u305f\u306f\u5b9f\u884c\u306b\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<code>pytest.mark<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u306e\u767b\u9332\u65b9\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b<\/strong>: OR \u30d5\u30a1\u30a4\u30eb\u304c\u307e\u3060\u306a\u3044\u5834\u5408\u306f\u3001\u4f5c\u6210\u3057\u307e\u3059\u3002<code>pytest.ini<\/code><code>pyproject.toml<\/code><\/li>\n\n\n\n<li>\u30bf\u30b0<strong>\u306e\u767b\u9332<\/strong>: \u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3067\u3001\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u4f7f\u7528\u3057\u3066\u30ab\u30b9\u30bf\u30e0 \u30bf\u30b0\u3092\u767b\u9332\u3057\u307e\u3059\u3002<code>markers<\/code><ul><li>\u30d5\u30a1\u30a4\u30eb\u5185:<code>pytest.ini<\/code><\/li><\/ul>\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b<code>[pytest] markers = my_marker: description of my custom marker<\/code><ul><li>\u30d5\u30a1\u30a4\u30eb\u5185:<code>pyproject.toml<\/code><\/li><\/ul>toml\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b<code>[tool.pytest.ini_options] markers = [ \"my_marker: description of my custom marker\", ]<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u306e\u4f7f\u7528\u65b9\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c6\u30b9\u30c8\u95a2\u6570\u306b\u8ffd\u52a0<\/strong>: \u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\u3092\u4f7f\u7528\u3057\u3066\u3001\u30ab\u30b9\u30bf\u30e0\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u3092\u30c6\u30b9\u30c8\u95a2\u6570\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002 pythonCopy code<code>@pytest.mark.MY_MARKER_NAME<\/code><code>@pytest.mark.my_marker def test_with_custom_marker(): pass<\/code><\/li>\n\n\n\n<li>\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b:&nbsp;<strong>\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u30c6\u30b9\u30c8<\/strong>\u3092\u5b9f\u884c\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>-m<\/code><code>pytest -m my_marker<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u65b9\u6cd5<\/h4>\n\n\n\n<p>\u3001\u3001) \u306a\u3069\u306e\u8ad6\u7406\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3057\u3066\u3001\u30ab\u30b9\u30bf\u30e0 \u30bf\u30b0\u3068\u7d44\u307f\u8fbc\u307f\u30bf\u30b0\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<code>and<\/code><code>or<\/code><code>not<\/code><\/p>\n\n\n\n<p>\u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<\/p>\n\n\n\n<p><code>pytest -m \"my_marker and not slow\"<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b46\u8a18<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u540d\u524d\u306e\u7af6\u5408\u3092\u907f\u3051\u308b<\/strong>: \u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u540d\u304c\u7d44\u307f\u8fbc\u307f\u30bf\u30b0\u3084\u4ed6\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30bf\u30b0\u540d\u3068\u7af6\u5408\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u8aac\u660e<\/strong>: \u4ed6\u306e\u958b\u767a\u8005\u304c\u305d\u306e\u76ee\u7684\u3092\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u3001\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u306e\u8aac\u660e\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/strong>: \u3059\u3079\u3066\u306e\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3068\u305d\u306e\u76ee\u7684\u3092\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30c6\u30b9\u30c8\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u30ea\u30b9\u30c8\u3057\u3066\u3001\u30c1\u30fc\u30e0\u30e1\u30f3\u30d0\u30fc\u304c\u305d\u308c\u3089\u306e\u4f7f\u7528\u65b9\u6cd5\u3092\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u767b\u9332\u3001\u4f7f\u7528\u3001\u7d44\u307f\u5408\u308f\u305b\u306a\u3069\u3001Pytest\u3067\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3092\u4f5c\u6210\u3057\u3066\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u521d\u5fc3\u8005\u304cPytest\u306e\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u7279\u5b9a\u306e\u30bf\u30b0\u30c6\u30b9\u30c8ChatGPT\u3092\u5b9f\u884c\u3057\u3066\u3044\u308b\u30bf\u30b0\u306b\u3088\u308b\u30bf\u30b0\u4ed8\u3051\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u7279\u5b9a\u306e\u30bf\u30b0\u3067\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30bf\u30b0\u3068\u30e9\u30d9\u30eb\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u5c02\u7528\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u7279\u5b9a\u306e\u30bf\u30b0\u306e\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>pytest \u3067\u306f\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u3001\u7279\u5b9a\u306e\u30bf\u30b0 (\u307e\u305f\u306f\u30e9\u30d9\u30eb) \u3067\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002 \u3053\u308c\u306f\u3001\u73fe\u5728\u95a2\u5fc3\u306e\u3042\u308b\u7279\u5b9a\u306e\u6a5f\u80fd\u307e\u305f\u306f\u554f\u984c\u306b\u95a2\u9023\u3059\u308b\u30c6\u30b9\u30c8\u306e\u307f\u3092\u5b9f\u884c\u3059\u308b\u52b9\u7387\u7684\u306a\u65b9\u6cd5\u3067\u3059\u3002<code>-m<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u7279\u5b9a\u306e\u30bf\u30b0\u3067\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u57fa\u672c\u7684\u306a\u4f7f\u7528\u65b9\u6cd5<\/strong>: \u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u5f8c\u306b\u30bf\u30b0\u540d\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 bashCopy \u30b3\u30fc\u30c9 \u3053\u308c\u306f\u3001\u30bf\u30b0\u3067\u30de\u30fc\u30af\u3055\u308c\u305f\u30c6\u30b9\u30c8\u306e\u307f\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<code>-m<\/code><code>pytest -m slow&nbsp;<\/code><code>@pytest.mark.slow<\/code><\/li>\n\n\n\n<li>\u7279\u5b9a\u306e\u30bf\u30b0\u3092\u9664\u5916\u3059\u308b: \u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001<strong>\u7279\u5b9a\u306e\u30bf\u30b0<\/strong>\u3092\u6301\u3064\u30c6\u30b9\u30c8\u3092\u9664\u5916\u3057\u307e\u3059\u3002 bashCopy \u30b3\u30fc\u30c9 \u3053\u308c\u306b\u3088\u308a\u3001\u30de\u30fc\u30af\u3055\u308c\u3066\u3044\u306a\u3044\u3059\u3079\u3066\u306e\u30c6\u30b9\u30c8\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<code>not<\/code><code>pytest -m \"not slow\"&nbsp;<\/code><code>@pytest.mark.slow<\/code><\/li>\n\n\n\n<li><strong>\u8907\u6570\u306e\u30c8\u30fc\u30af\u30f3\u3092\u7d50\u5408\u3059\u308b<\/strong>: \u3001) \u306a\u3069\u306e\u8ad6\u7406\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3057\u3066\u3001\u8907\u6570\u306e\u30bf\u30b0\u3092\u7d50\u5408\u3057\u307e\u3059\u3002 bashCopy \u30b3\u30fc\u30c9: \u3053\u308c\u306b\u3088\u308a\u3001 \u3068 \u306e\u4e21\u65b9\u3067\u30de\u30fc\u30af\u3055\u308c\u305f\u30c6\u30b9\u30c8\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<code>and<\/code><code>or<\/code><code>pytest -m \"slow and regression\"&nbsp;<\/code><code>@pytest.mark.slow<\/code><code>@pytest.mark.regression<\/code><\/li>\n\n\n\n<li><strong>OR \u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3059\u308b<\/strong>: \u3044\u305a\u308c\u304b\u306e\u30d5\u30e9\u30b0\u3092\u4f7f\u7528\u3057\u3066\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u5834\u5408\u306f\u3001\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>or<\/code><code>pytest -m \"slow or regression\"<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u62ec\u5f27\u3092\u4f7f\u7528\u3059\u308b: \u30bf\u30b0\u306e\u8907\u96d1\u306a\u7d44\u307f\u5408\u308f\u305b\u304c\u3042\u308b\u5834\u5408\u306f\u3001<strong>\u62ec\u5f27<\/strong>\u3092\u4f7f\u7528\u3057\u3066\u512a\u5148\u9806\u4f4d\u3092\u660e\u78ba\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>pytest -m \"(slow or regression) and not smoke\"<\/code><\/li>\n\n\n\n<li><strong>\u30ab\u30b9\u30bf\u30e0<\/strong>\u30bf\u30b0: \u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u5834\u5408\u3082\u540c\u69d8\u3067\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>pytest -m my_custom_marker<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b46\u8a18<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30bf\u30b0\u3092\u767b\u9332\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059<\/strong>: \u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3092\u542b\u3081\u3001\u5b9f\u884c\u3059\u308b\u3059\u3079\u3066\u306e\u30bf\u30b0\u304c OR \u30d5\u30a1\u30a4\u30eb\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<code>pytest.ini<\/code><code>pyproject.toml<\/code><\/li>\n\n\n\n<li><strong>\u5927\u6587\u5b57\u3068\u5c0f\u6587\u5b57<\/strong>\u304c\u533a\u5225\u3055\u308c\u307e\u3059: \u30bf\u30b0\u540d\u3067\u306f\u5927\u6587\u5b57\u3068\u5c0f\u6587\u5b57\u304c\u533a\u5225\u3055\u308c\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u6b63\u3057\u3044\u5927\u6587\u5b57\u3068\u5c0f\u6587\u5b57\u304c\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001pytest\u3067\u7279\u5b9a\u306e\u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u57fa\u672c\u7684\u306a\u4f7f\u7528\u6cd5\u3001\u7279\u5b9a\u306e\u30bf\u30b0\u306e\u9664\u5916\u3001\u8907\u6570\u306e\u30bf\u30b0\u306e\u7d50\u5408\u3001\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5\u306a\u3069\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u521d\u5fc3\u8005\u304cpytest\u3067\u30de\u30fc\u30af\u30a2\u30c3\u30d7\u3092\u4f7f\u7528\u3057\u3066\u7279\u5b9a\u306e\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>ChatGPT\u3067\u4f8b\u5916\u3092\u51e6\u7406\u3059\u308b\u305f\u3081\u306bpytest.rais\u3092\u4f7f\u7528\u3057\u3066\u4f8b\u5916\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5\u3092\u8a73\u7d30\u306b\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u4f7f\u7528\u306b\u4f34\u3046\u4f8b\u5916\u306e\u51e6\u7406\u300d\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u4f8b\u5916\u306e\u51e6\u7406\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u30b3\u30a2 \u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u6a5f\u80fd\u3057\u307e\u3059\u3002<code>pytest.raises<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f8b\u5916\u3092\u51e6\u7406\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059<code>pytest.raises<\/code><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p><code>pytest.raises<\/code>&nbsp;\u306f\u3001\u4f8b\u5916\u3092\u30ad\u30e3\u30c3\u30c1\u3057\u3066\u30c6\u30b9\u30c8\u3059\u308b\u305f\u3081\u306e pytest \u7d44\u307f\u8fbc\u307f\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30de\u30cd\u30fc\u30b8\u30e3\u30fc\u3067\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u304c\u7279\u5b9a\u306e\u7a2e\u985e\u306e\u4f8b\u5916\u3092\u671f\u5f85\u3069\u304a\u308a\u306b\u30b9\u30ed\u30fc\u3059\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u4f8b\u5916\u3092\u30ad\u30e3\u30c3\u30c1\u3059\u308b<\/strong>: \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3001\u7279\u5b9a\u306e\u7a2e\u985e\u306e\u4f8b\u5916\u3092\u30ad\u30e3\u30c3\u30c1\u3057\u307e\u3059\u3002 \u3053\u306e\u4f8b\u306epythonCopy\u30b3\u30fc\u30c9\u306f\u3001\u30b9\u30ed\u30fc\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u305d\u306e\u5834\u5408\u3001\u30c6\u30b9\u30c8\u306f\u5408\u683c\u3057\u307e\u3059\u3002<code>with<\/code><code>pytest.raises<\/code><code>import pytest def test_divide_by_zero(): with pytest.raises(ZeroDivisionError): 1 \/ 0&nbsp;<\/code><code>1 \/ 0<\/code><code>ZeroDivisionError<\/code><\/li>\n\n\n\n<li>\u4f8b\u5916\u30e1\u30c3\u30bb\u30fc\u30b8<strong>\u3092\u78ba\u8a8d\u3059\u308b<\/strong>: \u4f8b\u5916\u306e\u30a8\u30e9\u30fc \u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u671f\u5f85\u3069\u304a\u308a\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002 pythonCopy code \u3053\u3053\u3067\u306f\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306f\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u7528\u3057\u3066\u3001\u30a8\u30e9\u30fc \u30e1\u30c3\u30bb\u30fc\u30b8\u306b &#8220;123&#8221; \u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<code>def test_value_error_message(): with pytest.raises(ValueError, match=r\".* 123 .*\"): raise ValueError(\"Exception 123 occurred\")&nbsp;<\/code><code>match<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong><code>as<\/code><\/strong>&nbsp;\u3092\u4f7f\u7528\u3057\u3066\u4f8b\u5916\u60c5\u5831\u3092\u53d6\u5f97: \u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u5b9f\u969b\u306b\u30b9\u30ed\u30fc\u3055\u308c\u305f\u4f8b\u5916\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002 pythonCopy \u30b3\u30fc\u30c9 \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u306f\u3001\u30b9\u30ed\u30fc\u3055\u308c\u305f\u4f8b\u5916\u306b\u95a2\u3059\u308b\u60c5\u5831\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<code>as<\/code><code>def test_get_exception_info(): with pytest.raises(ValueError) as excinfo: raise ValueError(\"Exception occurred\") assert \"Exception occurred\" in str(excinfo.value)&nbsp;<\/code><code>excinfo<\/code><\/li>\n\n\n\n<li><strong>\u30ab\u30b9\u30bf\u30e0\u4f8b\u5916<\/strong>: \u30ab\u30b9\u30bf\u30e0\u4f8b\u5916\u306b\u3082\u9069\u7528\u3055\u308c\u307e\u3059\u3002 pythonCopy code<code>pytest.raises<\/code><code>class CustomError(Exception): pass def test_custom_exception(): with pytest.raises(CustomError): raise CustomError(\"This is a custom exception\")<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b46\u8a18<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u4f8b\u5916\u3092\u30ad\u30e3\u30c3\u30c1\u3057\u306a\u3044<\/strong>: \u30b3\u30fc\u30c9\u304c\u4e88\u671f\u3057\u305f\u4f8b\u5916\u3092\u30b9\u30ed\u30fc\u3057\u306a\u3044\u5834\u5408\u3001\u30c6\u30b9\u30c8\u306f\u5931\u6557\u3057\u307e\u3059\u3002<code>pytest.raises<\/code><\/li>\n\n\n\n<li><strong>\u8907\u6570\u306e\u4f8b\u5916<\/strong>: \u30ad\u30e3\u30c3\u30c1\u3067\u304d\u308b\u4f8b\u5916\u306f 1 \u3064\u3060\u3051\u3067\u3059\u3002 \u8907\u6570\u306e\u4f8b\u5916\u3092\u30c6\u30b9\u30c8\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u8907\u6570\u306e\u30d6\u30ed\u30c3\u30af\u3092\u4f7f\u7528\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<code>pytest.raises<\/code><code>pytest.raises<\/code><\/li>\n\n\n\n<li><strong><code>try\/except<\/code><\/strong>&nbsp;\u3092\u907f\u3051\u308b: \u4f8b\u5916\u3092\u30c6\u30b9\u30c8\u3059\u308b\u3068\u304d\u306f\u3001\u30c6\u30b9\u30c8 \u30ed\u30b8\u30c3\u30af\u304c\u8907\u96d1\u306b\u306a\u308b\u305f\u3081\u3001\u30d6\u30ed\u30c3\u30af\u306e\u4f7f\u7528\u306f\u907f\u3051\u3066\u304f\u3060\u3055\u3044\u3002<code>try\/except<\/code><\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001pytest \u3067\u4f8b\u5916\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u57fa\u672c\u7684\u306a\u4f7f\u7528\u6cd5\u3001\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5\u3001\u8003\u616e\u4e8b\u9805\u306a\u3069\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u521d\u5fc3\u8005\u304cPytest\u3067\u4f8b\u5916\u3092\u51e6\u7406\u3059\u308b\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<code>pytest.raises<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>pytest.warns\u3092\u4f7f\u7528\u3057\u3066\u4f8b\u5916\u3092\u51e6\u7406\u3057\u3066\u8b66\u544a\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5\u3092\u8a73\u7d30\u306b\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044ChatGPT<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u8b66\u544a\u51e6\u7406\u306e\u4f7f\u7528\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u4f8b\u5916\u306e\u51e6\u7406\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u5c02\u7528\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<code>pytest.warns<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u8b66\u544a\u306e\u51e6\u7406\u306b\u4f7f\u7528\u3057\u307e\u3059<code>pytest.warns<\/code><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p><code>pytest.warns<\/code>&nbsp;\u306f\u3001\u8b66\u544a\u3092\u30ad\u30e3\u30d7\u30c1\u30e3\u3057\u3066\u30c6\u30b9\u30c8\u3059\u308b\u305f\u3081\u306e pytest \u7d44\u307f\u8fbc\u307f\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30de\u30cd\u30fc\u30b8\u30e3\u30fc\u3067\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u304c\u7279\u5b9a\u306e\u7a2e\u985e\u306e\u8b66\u544a\u3092\u671f\u5f85\u3069\u304a\u308a\u306b\u51fa\u529b\u3059\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u8b66\u544a\u306e\u30ad\u30e3\u30d7\u30c1\u30e3: \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3068\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3001\u7279\u5b9a\u306e\u7a2e\u985e\u306e\u8b66\u544a\u3092\u30ad\u30e3\u30d7\u30c1\u30e3<strong>\u3057\u307e\u3059<\/strong>\u3002 \u3053\u306e\u4f8b\u3067\u306f\u3001pythonCopy \u30b3\u30fc\u30c9\u3092\u751f\u6210\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u305d\u306e\u5834\u5408\u3001\u30c6\u30b9\u30c8\u306f\u5408\u683c\u3057\u307e\u3059\u3002<code>with<\/code><code>pytest.warns<\/code><code>import pytest import warnings def test_deprecation_warning(): with pytest.warns(DeprecationWarning): warnings.warn(\"deprecated\", DeprecationWarning)&nbsp;<\/code><code>warnings.warn(\"deprecated\", DeprecationWarning)<\/code><code>DeprecationWarning<\/code><\/li>\n\n\n\n<li><strong>\u8b66\u544a\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u78ba\u8a8d\u3059\u308b<\/strong>: \u8b66\u544a\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u671f\u5f85\u3069\u304a\u308a\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002 pythonCopy \u30b3\u30fc\u30c9 \u3053\u3053\u3067\u306f\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306f\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u7528\u3057\u3066\u3001\u8b66\u544a\u30e1\u30c3\u30bb\u30fc\u30b8\u306b &#8220;123&#8221; \u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<code>def test_specific_warning_message(): with pytest.warns(UserWarning, match=r\".* 123 .*\"): warnings.warn(\"Warning 123 occurred\")&nbsp;<\/code><code>match<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong><code>as<\/code>&nbsp;\u3092\u4f7f\u7528\u3057\u3066\u8b66\u544a\u60c5\u5831\u3092\u53d6\u5f97<\/strong>: \u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u5b9f\u969b\u306e\u8b66\u544a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002 pythonCopy \u30b3\u30fc\u30c9 \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u306f\u3001\u767a\u884c\u3055\u308c\u305f\u8b66\u544a\u306b\u95a2\u3059\u308b\u60c5\u5831\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<code>as<\/code><code>def test_get_warning_info(): with pytest.warns(UserWarning) as record: warnings.warn(\"User warning\") assert \"User warning\" in str(record[0].message)&nbsp;<\/code><code>record<\/code><\/li>\n\n\n\n<li><strong>\u8907\u6570\u306e\u8b66\u544a<\/strong>: \u30b3\u30fc\u30c9\u3067\u8907\u6570\u306e\u8b66\u544a\u304c\u767a\u884c\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u305d\u308c\u3089\u3092\u30ad\u30e3\u30c3\u30c1\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002 \u3053\u3053\u3067\u306epythonCopy\u30b3\u30fc\u30c9\u306f\u3001\u7279\u5b9a\u306e\u7a2e\u985e\u306e\u8b66\u544a\u3092\u6c17\u306b\u3057\u306a\u3044\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002<code>pytest.warns<\/code><code>def test_multiple_warnings(): with pytest.warns(None) as record: warnings.warn(\"User warning\") warnings.warn(\"Another warning\") assert len(record) == 2&nbsp;<\/code><code>None<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b46\u8a18<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u8b66\u544a<strong>\u306a\u3057<\/strong>: \u30b3\u30fc\u30c9\u304c\u4e88\u671f\u3057\u305f\u8b66\u544a\u3092\u767a\u884c\u3057\u306a\u3044\u5834\u5408\u3001\u30c6\u30b9\u30c8\u306f\u5931\u6557\u3057\u307e\u3059\u3002<code>pytest.warns<\/code><\/li>\n\n\n\n<li><strong>\u8b66\u544a<\/strong>\u306e\u7a2e\u985e: \u6b63\u3057\u3044\u8b66\u544a\u306e\u7a2e\u985e\u3092\u6307\u5b9a\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002 \u3088\u304f\u308f\u304b\u3089\u306a\u3044\u5834\u5408\u306f\u3001 \u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<code>None<\/code><\/li>\n\n\n\n<li>\u8b66\u544a<strong>\u3092\u7121\u8996\u3057\u306a\u3044<\/strong>: \u8b66\u544a\u3092\u30c6\u30b9\u30c8\u3059\u308b\u3068\u304d\u306f\u3001\u30c6\u30b9\u30c8\u306e\u7cbe\u5ea6\u306b\u5f71\u97ff\u3092\u4e0e\u3048\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001\u4f7f\u7528\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<code>warnings.filterwarnings<\/code><\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001pytest \u3067\u8b66\u544a\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u3001\u57fa\u672c\u3001\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5\u3001\u8003\u616e\u4e8b\u9805\u306a\u3069\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u521d\u5fc3\u8005\u304cPyTest\u3067\u8b66\u544a\u306b\u5bfe\u51e6\u3059\u308b\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<code>pytest.warns<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u9ad8\u5ea6\u306a\u30c8\u30d4\u30c3\u30afChatGPT\u306e\u4e26\u5217\u30c6\u30b9\u30c8\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u4e26\u5217\u30c6\u30b9\u30c8\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u9ad8\u5ea6\u306a\u30c8\u30d4\u30c3\u30af\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u30b3\u30a2\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e26\u5217\u30c6\u30b9\u30c8<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>\u4e26\u5217\u30c6\u30b9\u30c8\u306f\u3001\u8907\u6570\u306e\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u3092\u540c\u6642\u306b\u5b9f\u884c\u3057\u3066\u3001\u5168\u4f53\u7684\u306a\u30c6\u30b9\u30c8\u5b9f\u884c\u6642\u9593\u3092\u77ed\u7e2e\u3067\u304d\u308b\u30c6\u30b9\u30c8\u6700\u9069\u5316\u624b\u6cd5\u3067\u3059\u3002 pytest \u3067\u306f\u3001\u306a\u3069\u306e\u30b5\u30fc\u30c9\u30d1\u30fc\u30c6\u30a3\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u7528\u3057\u3066\u3001\u4e26\u5217\u30c6\u30b9\u30c8\u3092\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002<code>pytest-xdist<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">pytest-xdist \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h4>\n\n\n\n<p>\u307e\u305a\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<code>pytest-xdist<\/code><\/p>\n\n\n\n<p>\u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<\/p>\n\n\n\n<p><code>pip install pytest-xdist<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u4e26\u5217\u30c6\u30b9\u30c8\u306e\u5b9f\u884c<\/strong>: \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3001\u305d\u306e\u5f8c\u306b\u4f7f\u7528\u3059\u308b CPU \u30b3\u30a2\u306e\u6570\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002 bashCopy code\u3053\u308c\u306b\u3088\u308a\u30014\u3064\u306eCPU\u30b3\u30a2\u3068\u4e26\u884c\u3057\u3066\u30c6\u30b9\u30c8\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<code>-n<\/code><code>pytest -n 4<\/code><\/li>\n\n\n\n<li>CPU \u30b3\u30a2\u306e\u81ea\u52d5\u691c\u51fa: \u3053\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u4f7f\u7528\u3057\u3066\u3001\u4f7f\u7528\u53ef\u80fd\u306a\u3059\u3079\u3066\u306e CPU \u30b3\u30a2\u3092\u81ea\u52d5\u7684\u306b<strong>\u691c\u51fa<\/strong>\u3057\u3066\u4f7f\u7528\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>auto<\/code><code>pytest -n auto<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5206\u6563\u30c6\u30b9\u30c8<\/strong>: \u307e\u305f\u3001\u8907\u6570\u306e\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u30fc\u306b\u5206\u6563\u3055\u308c\u305f\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>pytest-xdist<\/code><code>pytest --dist=loadscope<\/code><\/li>\n\n\n\n<li>\u7279\u5b9a\u306e\u30bf\u30b0\u3067\u4e26\u5217\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b:&nbsp;<strong>\u7279\u5b9a\u306e\u30bf\u30b0\u3067\u4e26\u5217\u30c6\u30b9\u30c8<\/strong>\u3092\u5b9f\u884c\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>-m<\/code><code>pytest -n 4 -m \"slow\"<\/code><\/li>\n\n\n\n<li><strong>\u30ea\u30bd\u30fc\u30b9\u306e\u5206\u96e2<\/strong>: \u4e26\u5217\u30c6\u30b9\u30c8\u3067\u306f\u3001\u5404\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u304c\u72ec\u7acb\u3057\u3066\u304a\u308a\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u306a\u72b6\u614b\u3084\u30ea\u30bd\u30fc\u30b9\u3092\u5171\u6709\u3057\u3066\u3044\u306a\u3044\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b46\u8a18<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b9\u30ec\u30c3\u30c9\u30bb\u30fc\u30d5<\/strong>: \u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u3068\u4f7f\u7528\u3055\u308c\u308b\u5171\u6709\u30ea\u30bd\u30fc\u30b9\u304c\u30b9\u30ec\u30c3\u30c9\u30bb\u30fc\u30d5\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u5206\u96e2<\/strong>: \u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u64cd\u4f5c\u304c\u542b\u307e\u308c\u308b\u5834\u5408\u306f\u3001\u5404\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u306b\u72ec\u81ea\u306e\u72ec\u7acb\u3057\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9 \u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u304c\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30ed\u30b0<\/strong>\u3068\u51fa\u529b: \u4e26\u5217\u30c6\u30b9\u30c8\u3067\u306f\u3001\u30ed\u30b0\u3068\u30b3\u30f3\u30bd\u30fc\u30eb\u51fa\u529b\u304c\u4e71\u96d1\u306b\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002 \u9069\u5207\u306a\u30ed\u30b0 \u30dd\u30ea\u30b7\u30fc\u304c\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u4f9d\u5b58\u95a2\u4fc2<\/strong>: \u4e26\u5217\u30c6\u30b9\u30c8\u306f\u5b9f\u884c\u9806\u5e8f\u3092\u4e71\u3059\u305f\u3081\u3001\u4f9d\u5b58\u95a2\u4fc2\u3092\u6301\u3064\u30c6\u30b9\u30c8 \u30b1\u30fc\u30b9\u306e\u4f5c\u6210\u306f\u907f\u3051\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001pytest \u3067\u4e26\u5217\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u57fa\u672c\u7684\u306a\u4f7f\u7528\u6cd5\u3001\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5\u3001\u8003\u616e\u4e8b\u9805\u306a\u3069\u3092\u542b\u3081\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u30c6\u30b9\u30c8\u306e\u901f\u5ea6\u3068\u52b9\u7387\u3092\u6700\u9069\u5316\u3057\u305f\u3044\u4e0a\u7d1a\u30e6\u30fc\u30b6\u30fc\u306b\u3001\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30aa\u30d7\u30b7\u30e7\u30f3ChatGPT\u3092\u4f7f\u7528\u3057\u3066\u9ad8\u5ea6\u306a\u30c8\u30d4\u30c3\u30af\u3092\u8a73\u7d30\u306b\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u4f7f\u7528\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u9ad8\u5ea6\u306a\u30c8\u30d4\u30c3\u30af\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u5c02\u7528\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30b3\u30de\u30f3\u30c9 \u30e9\u30a4\u30f3 \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3059\u308b<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>pytest \u306b\u306f\u3001\u30c6\u30b9\u30c8\u5b9f\u884c\u306e\u52d5\u4f5c\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u305f\u3081\u306e\u3055\u307e\u3056\u307e\u306a\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002 \u3053\u308c\u3089\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u30c6\u30b9\u30c8\u306e\u691c\u51fa\u3001\u5b9f\u884c\u3001\u30ec\u30dd\u30fc\u30c8\u4f5c\u6210\u3001\u304a\u3088\u3073\u305d\u306e\u4ed6\u306e\u591a\u304f\u306e\u5074\u9762\u3092\u5236\u5fa1\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30c6\u30b9\u30c8 \u30d5\u30a1\u30a4\u30eb\u3068\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u6307\u5b9a\u3059\u308b: \u30b3\u30de\u30f3\u30c9 \u30e9\u30a4\u30f3\u3067\u76f4\u63a5\u5b9f\u884c\u3059\u308b<strong>\u30c6\u30b9\u30c8 \u30d5\u30a1\u30a4\u30eb\u307e\u305f\u306f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea<\/strong>\u3092\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>pytest tests\/test_example.py<\/code><\/li>\n\n\n\n<li><strong>\u7279\u5b9a\u306e\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b<\/strong>: \u30b7\u30f3\u30dc\u30eb\u3092\u4f7f\u7528\u3057\u3066\u3001\u7279\u5b9a\u306e\u30c6\u30b9\u30c8\u95a2\u6570\u307e\u305f\u306f\u30c6\u30b9\u30c8 \u30af\u30e9\u30b9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>::<\/code><code>pytest tests\/test_example.py::test_function<\/code><\/li>\n\n\n\n<li><strong>\u30bf\u30b0\u306e\u30d5\u30a3\u30eb\u30bf\u30fc\u51e6\u7406<\/strong>: \u7279\u5b9a\u306e\u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>-m<\/code><code>pytest -m slow<\/code><\/li>\n\n\n\n<li><strong>\u30ad\u30fc\u30ef\u30fc\u30c9\u5f0f<\/strong>: \u540d\u524d\u304c\u7279\u5b9a\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u3068\u4e00\u81f4\u3059\u308b\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u306b\u306f\u3001\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>-k<\/code><code>pytest -k \"TestExample and not slow\"<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u51fa\u529b\u306e\u8a73\u7d30\u5ea6\u306e\u5909\u66f4: \u304a\u3088\u3073\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u3001\u51fa\u529b<strong>\u306e\u8a73\u7d30\u5ea6<\/strong>\u3092\u5236\u5fa1\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>-v<\/code><code>-q<\/code><code>pytest -v # Verbose pytest -q # Quiet<\/code><\/li>\n\n\n\n<li><strong>\u30c6\u30b9\u30c8\u30ec\u30dd\u30fc\u30c8\u306e\u751f\u6210<\/strong>: JUnit\u5f62\u5f0f\u306e\u30c6\u30b9\u30c8\u30ec\u30dd\u30fc\u30c8\u3092\u751f\u6210\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>--junitxml<\/code><code>pytest --junitxml=report.xml<\/code><\/li>\n\n\n\n<li>\u5931\u6557\u3057\u305f\u518d\u8a66\u884c: \u3053\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u3001<strong>\u5931\u6557\u3057\u305f\u518d\u8a66\u884c<\/strong>\u306e\u56de\u6570\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>--maxfail<\/code><code>pytest --maxfail=3<\/code><\/li>\n\n\n\n<li>\u4e26\u5217\u5b9f\u884c: \u65e2\u306b \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u30c6\u30b9\u30c8\u3092<strong>\u4e26\u5217<\/strong>\u5b9f\u884c\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>pytest-xdist<\/code><code>-n<\/code><code>pytest -n 4<\/code><\/li>\n\n\n\n<li><strong>\u30ab\u30b9\u30bf\u30e0<\/strong>\u30d7\u30e9\u30b0\u30a4\u30f3\u30aa\u30d7\u30b7\u30e7\u30f3:\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u305fpytest\u30d7\u30e9\u30b0\u30a4\u30f3\u306f\u3001\u8ffd\u52a0\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u63d0\u4f9b\u3059\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>pytest --some-plugin-option=value<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b46\u8a18<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u7af6\u5408\u3092\u907f\u3051\u308b<\/strong>: \u30ab\u30b9\u30bf\u30e0\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30aa\u30d7\u30b7\u30e7\u30f3\u304c pytest \u3084\u4ed6\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u7af6\u5408\u3057\u306a\u3044\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n\n\n\n<li><strong>\u69cb\u6210\u30d5\u30a1\u30a4\u30eb<\/strong>: \u591a\u304f\u306e\u30b3\u30de\u30f3\u30c9 \u30e9\u30a4\u30f3 \u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u3001OR \u30d5\u30a1\u30a4\u30eb\u3067\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<code>pytest.ini<\/code><code>pyproject.toml<\/code><\/li>\n\n\n\n<li><strong>\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u4e92\u63db\u6027<\/strong>: \u30d7\u30e9\u30b0\u30a4\u30f3\u95a2\u9023\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u306f\u3001pytest \u3068\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306b\u4e92\u63db\u6027\u304c\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001pytest\u3067\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u57fa\u672c\u3001\u8a73\u7d30\u3001\u6ce8\u610f\u4e8b\u9805\u306a\u3069\u3092\u542b\u3081\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u4e0a\u7d1a\u30e6\u30fc\u30b6\u30fc\u304cpytest\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>\u9ad8\u5ea6\u306a\u30c8\u30d4\u30c3\u30af\u306e CI\/CD \u30d1\u30a4\u30d7\u30e9\u30a4\u30f3 ChatGPT \u3078\u306e\u7d71\u5408\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u3053\u3053\u3067\u306f\u300cCI\/CD \u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3078\u306e\u7d71\u5408\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3092\u793a\u3057\u307e\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u9ad8\u5ea6\u306a\u30c8\u30d4\u30c3\u30af\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u306a\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">CI\/CD \u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3078\u306e\u7d71\u5408<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>CI\/CD (\u7d99\u7d9a\u7684\u30a4\u30f3\u30c6\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\/\u7d99\u7d9a\u7684\u30c7\u30d7\u30ed\u30a4) \u306f\u3001\u6700\u65b0\u306e\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u958b\u767a\u306e\u91cd\u8981\u306a\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u3059\u3002 pytest \u3092 CI\/CD \u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306b\u7d71\u5408\u3059\u308b\u3053\u3068\u3067\u3001\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u3092\u81ea\u52d5\u5316\u3057\u3001\u30b3\u30fc\u30c9\u306e\u5909\u66f4\u306b\u3088\u3063\u3066\u65e2\u5b58\u306e\u6a5f\u80fd\u304c\u640d\u306a\u308f\u308c\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30c6\u30b9\u30c8 \u30b9\u30c6\u30c3\u30d7\u3092\u8ffd\u52a0\u3059\u308b: CI\/CD \u69cb\u6210\u30d5\u30a1\u30a4\u30eb (\u3001\u3001\u3001\u306a\u3069) \u306b\u3001pytest \u3092\u5b9f\u884c\u3059\u308b<strong>\u30b9\u30c6\u30c3\u30d7<\/strong>\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 yaml\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b<code>.gitlab-ci.yml<\/code><code>Jenkinsfile<\/code><code>github-actions.yml<\/code><code># \u793a\u4f8b\uff1aGitHub Actions jobs: test: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions\/checkout@v2 - name: Set up Python uses: actions\/setup-python@v2 - name: Install dependencies run: pip install -r requirements.txt - name: Run tests run: pytest<\/code><\/li>\n\n\n\n<li>\u4f9d\u5b58\u95a2\u4fc2<strong>\u306e\u30ad\u30e3\u30c3\u30b7\u30e5<\/strong>: \u30c6\u30b9\u30c8\u3092\u9ad8\u901f\u5316\u3059\u308b\u305f\u3081\u306b\u3001\u4f9d\u5b58\u95a2\u4fc2\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u3067\u304d\u307e\u3059\u3002 yaml\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b<code># \u793a\u4f8b\uff1a\u7f13\u5b58 Python \u4f9d\u8d56 - name: Cache dependencies uses: actions\/cache@v2 with: path: ~\/.cache\/pip key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u4e26\u5217<\/strong>\u30c6\u30b9\u30c8: \u30c6\u30b9\u30c8 \u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u5927\u304d\u3044\u5834\u5408\u306f\u3001\u4e26\u5217\u30c6\u30b9\u30c8\u3092\u4f7f\u7528\u3057\u3066\u30c6\u30b9\u30c8\u6642\u9593\u3092\u77ed\u7e2e\u3059\u308b\u3053\u3068\u3092\u691c\u8a0e\u3057\u3066\u304f\u3060\u3055\u3044\u3002 yaml\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b<code># \u793a\u4f8b\uff1a\u4f7f\u7528 pytest-xdist \u8fdb\u884c\u5e76\u884c\u6d4b\u8bd5 - name: Run tests in parallel run: pytest -n auto<\/code><\/li>\n\n\n\n<li><strong>\u6761\u4ef6\u4ed8\u304d\u30c6\u30b9\u30c8<\/strong>: \u30c8\u30ea\u30ac\u30fc\u3055\u308c\u305f\u30a4\u30d9\u30f3\u30c8\u307e\u305f\u306f\u30d6\u30e9\u30f3\u30c1\u306b\u57fa\u3065\u3044\u3066\u7279\u5b9a\u306e\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002 yaml\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b<code># \u793a\u4f8b\uff1a\u53ea\u5728 master \u5206\u652f\u4e0a\u8fd0\u884c \"slow\" \u6807\u8bb0\u7684\u6d4b\u8bd5 - name: Run slow tests on master if: github.ref == 'refs\/heads\/master' run: pytest -m slow<\/code><\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8 \u30ec\u30dd\u30fc\u30c8\u3092\u751f\u6210\u3057\u3066\u767a\u884c\u3059\u308b:&nbsp;<strong>\u30c6\u30b9\u30c8 \u30ec\u30dd\u30fc\u30c8\u3092\u81ea\u52d5\u7684\u306b\u751f\u6210\u3057\u3001<\/strong>CI\/CD \u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u306b\u767a\u884c\u3057\u307e\u3059\u3002 yaml\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b<code># \u793a\u4f8b\uff1a\u751f\u6210 JUnit \u683c\u5f0f\u7684\u6d4b\u8bd5\u62a5\u544a - name: Generate test report run: pytest --junitxml=report.xml<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b46\u8a18<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u74b0\u5883\u5909\u6570<\/strong>: \u5fc5\u8981\u306a\u3059\u3079\u3066\u306e\u74b0\u5883\u5909\u6570\u304c CI\/CD \u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3067\u6b63\u3057\u304f\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u6a5f\u5bc6\u60c5\u5831<\/strong>: \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u8a8d\u8a3c\u60c5\u5831\u3084 API \u30ad\u30fc\u306a\u3069\u306e\u6a5f\u5bc6\u60c5\u5831\u3092 CI\/CD \u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u306b\u30cf\u30fc\u30c9\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3057\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002<\/li>\n\n\n\n<li><strong>\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u4e92\u63db\u6027<\/strong>: CI\/CD \u74b0\u5883\u306e pytest \u3068\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u74b0\u5883\u3068\u4e00\u81f4\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30ea\u30bd\u30fc\u30b9<\/strong>\u5236\u9650: \u6ce8 CI\/CD \u30b5\u30fc\u30d3\u30b9\u306b\u306f\u3001\u6700\u5927\u5b9f\u884c\u6642\u9593\u3084\u4e26\u5217\u30bf\u30b9\u30af\u306e\u6570\u306a\u3069\u306e\u30ea\u30bd\u30fc\u30b9\u5236\u9650\u304c\u3042\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001pytest \u3067 CI\/CD \u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306b\u7d71\u5408\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u57fa\u672c\u7684\u306a\u4f7f\u7528\u6cd5\u3001\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5\u3001\u8003\u616e\u4e8b\u9805\u306a\u3069\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u4e0a\u7d1a\u30e6\u30fc\u30b6\u30fc\u304c pytest \u3068 CI\/CD \u7d71\u5408\u306e\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>ChatGPT\u3092\u6574\u7406\u3059\u308b\u305f\u3081\u306e\u30b3\u30fc\u30c9\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3092\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u30b3\u30fc\u30c9\u7de8\u6210\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30d9\u30b9\u30c8 \u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u306a\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u6a5f\u80fd\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30b3\u30fc\u30c9\u7de8\u6210<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>\u30b3\u30fc\u30c9\u7de8\u6210\u306f\u3001\u30c6\u30b9\u30c8\u30fb\u30b3\u30fc\u30c9\u3001\u30c6\u30b9\u30c8\u30fb\u30c7\u30fc\u30bf\u3001\u304a\u3088\u3073\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3092\u69cb\u9020\u5316\u3057\u3066\u3001\u4fdd\u5b88\u3001\u62e1\u5f35\u3001\u304a\u3088\u3073\u30b3\u30e9\u30dc\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5bb9\u6613\u306b\u3059\u308b\u30c6\u30b9\u30c8\u30fb\u30a8\u30f3\u30b8\u30cb\u30a2\u30ea\u30f3\u30b0\u306e\u91cd\u8981\u306a\u5074\u9762\u3067\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u9020<\/strong>: \u901a\u5e38\u3001\u30c6\u30b9\u30c8 \u30b3\u30fc\u30c9\u306f \u3068\u3044\u3046\u540d\u524d\u306e\u5225\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u683c\u7d0d\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b<code>tests<\/code><code>my_project\/ \u251c\u2500\u2500 src\/ \u251c\u2500\u2500 tests\/ \u2502 \u251c\u2500\u2500 unit\/ \u2502 \u251c\u2500\u2500 integration\/ \u2502 \u2514\u2500\u2500 e2e\/ \u2514\u2500\u2500 pytest.ini<\/code><\/li>\n\n\n\n<li><strong>\u547d\u540d\u898f\u5247<\/strong>: \u30c6\u30b9\u30c8 \u30d5\u30a1\u30a4\u30eb\u306f\u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u3067\u59cb\u307e\u308a\u3001\u30c6\u30b9\u30c8\u95a2\u6570\u3068\u30e1\u30bd\u30c3\u30c9\u306f \u3067\u59cb\u307e\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 pythonCopy code<code>test_<\/code><code>test_<\/code><code># \u6587\u4ef6\u540d: test_example.py def test_addition(): assert 1 + 1 == 2<\/code><\/li>\n\n\n\n<li>\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u4f7f\u7528\u3059\u308b:\u4e00\u822c\u7684\u306b\u4f7f\u7528\u3055\u308c\u308b\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u30b3\u30fc\u30c9\u3092<strong>\u30d5\u30a3\u30af\u30b9\u30c1\u30e3<\/strong>\u306b\u5165\u308c\u3066\u3001\u7c21\u5358\u306b\u518d\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002 pythonCopy code<code>@pytest.fixture def sample_data(): return {\"key\": \"value\"}<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30e2\u30b8\u30e5\u30fc\u30eb \u30ec\u30d9\u30eb\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3: \u8907\u6570\u306e\u30c6\u30b9\u30c8\u95a2\u6570\u307e\u305f\u306f\u30af\u30e9\u30b9\u9593\u3067\u5171\u6709\u3055\u308c\u308b\u30ea\u30bd\u30fc\u30b9\u306b\u306f\u3001\u30e2\u30b8\u30e5\u30fc\u30eb \u30ec\u30d9\u30eb\u307e\u305f\u306f<strong>\u30bb\u30c3\u30b7\u30e7\u30f3 \u30ec\u30d9\u30eb\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3<\/strong>\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 pythonCopy code<code>@pytest.fixture(scope=\"module\") def db_connection(): # Setup code yield connection # Teardown code<\/code><\/li>\n\n\n\n<li><strong>\u30d1\u30e9\u30e1\u30c8\u30ea\u30c3\u30af\u30c6\u30b9\u30c8<\/strong>:pytest\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u6a5f\u80fd\u3092\u4f7f\u7528\u3057\u3066\u3001\u91cd\u8907\u30b3\u30fc\u30c9\u3092\u6e1b\u3089\u3057\u307e\u3059\u3002 pythonCopy code<code>@pytest.mark.parametrize(\"input,expected\", [(1, 2), (2, 3), (3, 4)]) def test_increment(input, expected): assert input + 1 == expected<\/code><\/li>\n\n\n\n<li><strong>\u30bf\u30b0\u3068\u30bb\u30ec\u30af\u30bf\u30fc<\/strong>: \u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u30c6\u30b9\u30c8\u3092\u5206\u985e\u3057\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3 \u30bb\u30ec\u30af\u30bf\u30fc\u3092\u4f7f\u7528\u3057\u3066\u7279\u5b9a\u306e\u30c6\u30b9\u30c8 \u30bb\u30c3\u30c8\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002 pythonCopy \u30b3\u30fc\u30c9\u306e\u5b9f\u884c: bashCopy code<code>@pytest.mark.slow def test_slow_operation(): pass&nbsp;<\/code><code>pytest -m slow<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b46\u8a18<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30b0\u30ed\u30fc\u30d0\u30eb\u72b6\u614b\u3092\u907f\u3051\u308b: \u30c6\u30b9\u30c8\u306e\u72ec\u7acb\u6027\u306b\u5f71\u97ff\u3092\u4e0e\u3048\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001\u30c6\u30b9\u30c8\u3067<strong>\u30b0\u30ed\u30fc\u30d0\u30eb\u72b6\u614b<\/strong>\u307e\u305f\u306f\u30b7\u30f3\u30b0\u30eb\u30c8\u30f3\u3092\u4f7f\u7528\u3057\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002<\/li>\n\n\n\n<li>\u30ea\u30bd\u30fc\u30b9\u3092<strong>\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7<\/strong>\u3059\u308b: \u30c6\u30b9\u30c8\u306e\u5b8c\u4e86\u5f8c\u3001\u3059\u3079\u3066\u306e\u30ea\u30bd\u30fc\u30b9 (\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u3001\u30d5\u30a1\u30a4\u30eb\u306a\u3069) \u304c\u9069\u5207\u306b\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3068\u30b3\u30e1\u30f3\u30c8:\u8907\u96d1\u306a\u30c6\u30b9\u30c8\u3084\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306b\u9069\u5207\u306a\u91cf\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<strong>\u3068\u30b3\u30e1\u30f3\u30c8<\/strong>\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30d0\u30fc\u30b8\u30e7\u30f3<\/strong>\u7ba1\u7406: \u30c6\u30b9\u30c8 \u30b3\u30fc\u30c9\u3068\u30de\u30b9\u30bf\u30fc \u30b3\u30fc\u30c9\u3092\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u306b\u307e\u3068\u3081\u3066\u3001\u5909\u66f4\u3092\u8ffd\u8de1\u3057\u3001\u30c1\u30fc\u30e0\u306e\u30b3\u30e9\u30dc\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4fc3\u9032\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001pytest \u3067\u306e\u30b3\u30fc\u30c9\u7de8\u6210\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u306b\u3064\u3044\u3066\u3001\u57fa\u672c\u3001\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5\u3001\u8003\u616e\u4e8b\u9805\u306a\u3069\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u3042\u3089\u3086\u308b\u30ec\u30d9\u30eb\u306e\u958b\u767a\u8005\u3084\u30c6\u30b9\u30c8\u30a8\u30f3\u30b8\u30cb\u30a2\u304c\u3001pytest\u3067\u52b9\u7387\u7684\u306a\u30b3\u30fc\u30c9\u7de8\u6210\u306e\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>ChatGPT\u3067\u306e\u30c6\u30b9\u30c8\u30ab\u30d0\u30ec\u30c3\u30b8\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3092\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u30c6\u30b9\u30c8\u30ab\u30d0\u30ec\u30c3\u30b8\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30d9\u30b9\u30c8 \u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u306a\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u6a5f\u80fd\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30c6\u30b9\u30c8\u30ab\u30d0\u30ec\u30c3\u30b8<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>\u30c6\u30b9\u30c8 \u30ab\u30d0\u30ec\u30c3\u30b8\u306f\u3001\u30b3\u30fc\u30c9\u306e\u5408\u8a08\u91cf\u306b\u5bfe\u3059\u308b\u30c6\u30b9\u30c8\u4e2d\u306b\u5b9f\u884c\u3055\u308c\u305f\u30b3\u30fc\u30c9\u306e\u91cf\u306e\u6bd4\u7387\u3092\u8868\u3059\u30e1\u30c8\u30ea\u30c3\u30af\u3067\u3059\u3002 \u30c6\u30b9\u30c8\u306e\u5305\u62ec\u6027\u3068\u54c1\u8cea\u3092\u8a55\u4fa1\u3059\u308b\u305f\u3081\u306b\u3088\u304f\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30ab\u30d0\u30ec\u30c3\u30b8 \u30c4\u30fc\u30eb\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong>: \u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u7528\u3057\u3066\u30ab\u30d0\u30ec\u30c3\u30b8 \u30ec\u30dd\u30fc\u30c8\u3092\u7d71\u5408\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>pytest-cov<\/code><code>pip install pytest-cov<\/code><\/li>\n\n\n\n<li><strong>\u30ab\u30d0\u30ec\u30c3\u30b8 \u30c6\u30b9\u30c8\u306e\u5b9f\u884c<\/strong>: pytest \u3092\u5b9f\u884c\u3059\u308b\u3068\u304d\u306b\u3001\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 bashCopy \u30b3\u30fc\u30c9 \u3053\u308c\u306b\u3088\u308a\u3001\u5404\u30d5\u30a1\u30a4\u30eb\u306e\u30ab\u30d0\u30ec\u30c3\u30b8\u3092\u793a\u3059\u30ab\u30d0\u30ec\u30c3\u30b8 \u30ec\u30dd\u30fc\u30c8\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<code>--cov<\/code><code>pytest --cov=my_project<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>HTML \u30ec\u30dd\u30fc\u30c8\u306e\u751f\u6210: \u3053\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u3001HTML \u5f62\u5f0f\u306e\u30ab\u30d0\u30ec\u30c3\u30b8&nbsp;<strong>\u30ec\u30dd\u30fc\u30c8<\/strong>\u3092\u751f\u6210\u3057\u307e\u3059\u3002 bashCopy \u30b3\u30fc\u30c9 \u3053\u308c\u306b\u3088\u308a\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4e0b\u306b HTML \u30ec\u30dd\u30fc\u30c8\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<code>--cov-report<\/code><code>pytest --cov=my_project --cov-report html&nbsp;<\/code><code>htmlcov\/<\/code><\/li>\n\n\n\n<li>\u30ab\u30d0\u30ec\u30c3\u30b8\u3057\u304d\u3044\u5024\u306e\u8a2d\u5b9a: \u30c6\u30b9\u30c8\u304c\u5931\u6557\u3059\u308b<strong>\u30ab\u30d0\u30ec\u30c3\u30b8\u3057\u304d\u3044\u5024<\/strong>\u3092\u8a2d\u5b9a\u3067\u304d\u307e\u3059\u3002 bashCopy code\u3053\u308c\u306b\u3088\u308a\u3001\u30ab\u30d0\u30ec\u30c3\u30b8\u304c90%\u3092\u4e0b\u56de\u308b\u3068\u30c6\u30b9\u30c8\u304c\u5931\u6557\u3057\u307e\u3059\u3002<code>pytest --cov=my_project --cov-fail-under=90<\/code><\/li>\n\n\n\n<li><strong>\u30b3\u30fc\u30c9\u3092\u9664\u5916\u3059\u308b<\/strong>: \u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u7528\u3057\u3066\u3001\u7279\u5b9a\u306e\u30b3\u30fc\u30c9 \u30d6\u30ed\u30c3\u30af\u307e\u305f\u306f\u30d5\u30a1\u30a4\u30eb\u3092\u9664\u5916\u3057\u307e\u3059\u3002 \u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b<code>.coveragerc<\/code><code># .coveragerc [report] omit = my_project\/excluded_file.py<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b46\u8a18<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u552f\u4e00\u306e\u6307\u6a19<strong>\u3067\u306f\u306a\u3044<\/strong>: \u30ab\u30d0\u30ec\u30c3\u30b8\u306f\u6709\u7528\u306a\u6307\u6a19\u3067\u3059\u304c\u3001\u30c6\u30b9\u30c8\u306e\u54c1\u8cea\u3092\u8a55\u4fa1\u3059\u308b\u305f\u3081\u306e\u552f\u4e00\u306e\u57fa\u6e96\u3067\u3042\u3063\u3066\u306f\u306a\u308a\u307e\u305b\u3093\u3002<\/li>\n\n\n\n<li><strong>\u30ab\u30d0\u30ec\u30c3\u30b8<\/strong>&nbsp;\u30bf\u30a4\u30d7: \u30ab\u30d0\u30ec\u30c3\u30b8\u306b\u306f\u3001\u884c\u30ab\u30d0\u30ec\u30c3\u30b8\u3001\u30d6\u30e9\u30f3\u30c1 \u30ab\u30d0\u30ec\u30c3\u30b8\u3001\u95a2\u6570\u30ab\u30d0\u30ec\u30c3\u30b8\u306a\u3069\u3001\u3044\u304f\u3064\u304b\u306e\u30bf\u30a4\u30d7\u304c\u3042\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n\n\n\n<li><strong>\u7d99\u7d9a\u7684\u306a\u76e3\u8996<\/strong>: \u30ab\u30d0\u30ec\u30c3\u30b8 \u30c1\u30a7\u30c3\u30af\u3092 CI\/CD \u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306b\u7d71\u5408\u3057\u3066\u3001\u30ab\u30d0\u30ec\u30c3\u30b8\u306e\u5909\u66f4\u3092\u7d99\u7d9a\u7684\u306b\u76e3\u8996\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30b3\u30fc\u30c9<\/strong>&nbsp;\u30ec\u30d3\u30e5\u30fc: \u30b3\u30fc\u30c9 \u30ec\u30d3\u30e5\u30fc\u306e\u4e00\u90e8\u3068\u3057\u3066\u30ab\u30d0\u30ec\u30c3\u30b8 \u30ec\u30dd\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3001\u3055\u3089\u306b\u30c6\u30b9\u30c8\u304c\u5fc5\u8981\u306a\u9818\u57df\u3092\u7279\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001pytest \u306e\u30c6\u30b9\u30c8\u30ab\u30d0\u30ec\u30c3\u30b8\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u306b\u3064\u3044\u3066\u3001\u57fa\u672c\u3001\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5\u3001\u8003\u616e\u4e8b\u9805\u306a\u3069\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u958b\u767a\u8005\u3068\u30c6\u30b9\u30c8\u30a8\u30f3\u30b8\u30cb\u30a2\u304cpytest\u3067\u52b9\u679c\u7684\u306a\u30ab\u30d0\u30ec\u30c3\u30b8\u30c6\u30b9\u30c8\u306e\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>ChatGPT\u30ed\u30b0\u3068\u30ec\u30dd\u30fc\u30c8\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3092\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u30ed\u30b0\u3068\u30ec\u30dd\u30fc\u30c8\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306e\u300c\u30d9\u30b9\u30c8 \u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u91cd\u8981\u306a\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3068\u3057\u3066\u6a5f\u80fd\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u30ed\u30b0\u3068\u30ec\u30dd\u30fc\u30c8<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>\u30ed\u30b0\u3068\u30ec\u30dd\u30fc\u30c8\u306f\u3001\u30c6\u30b9\u30c8\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u8ffd\u8de1\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3060\u3051\u3067\u306a\u304f\u3001\u30c1\u30fc\u30e0\u306b\u8cb4\u91cd\u306a\u30d5\u30a3\u30fc\u30c9\u30d0\u30c3\u30af\u3092\u63d0\u4f9b\u3059\u308b\u305f\u3081\u306b\u3082\u3001\u30c6\u30b9\u30c8\u30d7\u30ed\u30bb\u30b9\u306e\u91cd\u8981\u306a\u90e8\u5206\u3067\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u7d44\u307f\u8fbc\u307f\u306e\u30ed\u30b0\u3092\u4f7f\u7528\u3059\u308b:pytest\u306f\u3001\u30c6\u30b9\u30c8\u3084\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3067\u4f7f\u7528\u3067\u304d\u308bPython\u306e<strong>\u7d44\u307f\u8fbc\u307f<\/strong>\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u307e\u3059\u3002 pythonCopy code<code>logging<\/code><code>import logging def test_logging(): logging.info(\"This is an info message\")<\/code><\/li>\n\n\n\n<li>\u7c21\u5358\u306a\u30ec\u30dd\u30fc\u30c8<strong>\u3092\u751f\u6210\u3059\u308b<\/strong>: \u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u3001pytest \u306f\u7c21\u5358\u306a\u30c6\u30b9\u30c8\u30ec\u30dd\u30fc\u30c8\u3092\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u51fa\u529b\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>pytest<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u8a73\u7d30\u30ec\u30dd\u30fc\u30c8\u306e\u751f\u6210<\/strong>: JUnit\u5f62\u5f0f\u3067\u8a73\u7d30\u306a\u30c6\u30b9\u30c8\u30ec\u30dd\u30fc\u30c8\u3092\u751f\u6210\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>--junitxml<\/code><code>pytest --junitxml=path\/to\/report.xml<\/code><\/li>\n\n\n\n<li><strong>\u30ab\u30b9\u30bf\u30e0\u30ed\u30b0\u69cb\u6210<\/strong>: \u30d5\u30a1\u30a4\u30eb\u5185\u306e\u30ed\u30b0\u8a2d\u5b9a\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3067\u304d\u307e\u3059\u3002 \u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3059\u308b<code>pytest.ini<\/code><code># pytest.ini [pytest] log_cli = true log_cli_level = INFO<\/code><\/li>\n\n\n\n<li>\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u7528\u3057\u3066\u30ec\u30dd\u30fc\u30c8\u3092\u751f\u6210\u3059\u308b: \u6b21\u306e\u3088\u3046\u306a\u3001\u3088\u308a\u8c4a\u5bcc\u306a\u30c6\u30b9\u30c8\u30ec\u30dd\u30fc\u30c8\u3092\u751f\u6210\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3067\u304d\u308b\u3044\u304f\u3064\u304b\u306epytest<strong>\u30d7\u30e9\u30b0\u30a4\u30f3<\/strong>\u304c\u3042\u308a\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>pytest-html<\/code><code>pip install pytest-html pytest --html=path\/to\/report.html<\/code><\/li>\n\n\n\n<li><strong>\u30ed\u30b0<\/strong>\u30ad\u30e3\u30d7\u30c1\u30e3: \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u3001\u6a19\u6e96\u51fa\u529b\u3068\u6a19\u6e96\u30a8\u30e9\u30fc\u306e\u30ad\u30e3\u30d7\u30c1\u30e3\u3092\u5236\u5fa1\u3057\u307e\u3059\u3002 \u30d0\u30c3\u30b7\u30e5\u30b3\u30d4\u30fc\u30b3\u30fc\u30c9<code>--capture<\/code><code>pytest --capture=no # \u4e0d\u6355\u83b7\u8f93\u51fa<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b46\u8a18<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30ed\u30b0\u30ec\u30d9\u30eb:\u7121\u99c4\u306a\u60c5\u5831\u3092\u51fa\u529b\u3057\u3059\u304e\u306a\u3044\u3088\u3046\u306b\u3001\u9069\u5207\u306a<strong>\u30ed\u30b0<\/strong>\u30ec\u30d9\u30eb\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n\n\n\n<li><strong>\u6a5f\u5bc6\u60c5\u5831<\/strong>: \u6a5f\u5bc6\u60c5\u5831\u3084\u500b\u4eba\u60c5\u5831\u3092\u30ed\u30b0\u3084\u30ec\u30dd\u30fc\u30c8\u306b\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3057\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002<\/li>\n\n\n\n<li><strong>\u30ec\u30dd\u30fc\u30c8\u306e\u4fdd\u5b58<\/strong>: \u30c6\u30b9\u30c8 \u30ec\u30dd\u30fc\u30c8\u304c\u5b89\u5168\u3067\u30a2\u30af\u30bb\u30b9\u53ef\u80fd\u306a\u5834\u6240\u306b\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u7d99\u7d9a\u7684\u30a4\u30f3\u30c6\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3<\/strong>: \u30ed\u30b0\u3068\u30ec\u30dd\u30fc\u30c8\u3092 CI\/CD \u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306b\u7d71\u5408\u3057\u3066\u3001\u3053\u306e\u30d7\u30ed\u30bb\u30b9\u3092\u81ea\u52d5\u5316\u3057\u3001\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306e\u30d5\u30a3\u30fc\u30c9\u30d0\u30c3\u30af\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u30b5\u30d6\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001pytest \u3067\u306e\u30ed\u30ae\u30f3\u30b0\u3068\u30ec\u30dd\u30fc\u30c8\u4f5c\u6210\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u306b\u3064\u3044\u3066\u3001\u57fa\u672c\u3001\u9ad8\u5ea6\u306a\u4f7f\u7528\u6cd5\u3001\u8003\u616e\u4e8b\u9805\u306a\u3069\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u958b\u767a\u8005\u3068\u30c6\u30b9\u30c8\u30a8\u30f3\u30b8\u30cb\u30a2\u304cPytest\u3067\u52b9\u679c\u7684\u306a\u30ed\u30b0\u3068\u30ec\u30dd\u30fc\u30c8\u751f\u6210\u306e\u5b66\u7fd2\u306e\u65c5\u3092\u59cb\u3081\u308b\u305f\u3081\u306e\u660e\u78ba\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u30d1\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/chat.openai.com\/_next\/image?url=https%3A%2F%2Flh3.googleusercontent.com%2Fa%2FACg8ocLh4B_kew_Ugyfq9egjobpny7AWdKDF1KOH64Elebx0ZhM%3Ds96-c&amp;w=96&amp;q=75\" alt=\"User\"\/><\/figure>\n\n\n\n<p>ChatGPT\u306e\u6b21\u306e\u30b9\u30c6\u30c3\u30d7\u306e\u305f\u3081\u306e\u3055\u3089\u306a\u308b\u5b66\u7fd2\u30ea\u30bd\u30fc\u30b9\u3067\u7d50\u8ad6\u3092\u8a73\u7d30\u306b\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<p>\u3082\u3061\u308d\u3093\u3001\u4ee5\u4e0b\u306f\u300c\u6b21\u306e\u30b9\u30c6\u30c3\u30d7\u306e\u305f\u3081\u306e\u7d50\u8ad6\u3068\u3055\u3089\u306a\u308b\u5b66\u7fd2\u30ea\u30bd\u30fc\u30b9\u300d\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3067\u3059\u3002 \u3053\u308c\u3067\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u306f\u7d42\u4e86\u3067\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u6b21\u306e\u30b9\u30c6\u30c3\u30d7\u306e\u305f\u3081\u306e\u3055\u3089\u306a\u308b\u5b66\u7fd2\u30ea\u30bd\u30fc\u30b9\u3092\u542b\u3080\u7d50\u8ad6<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u7d50\u8ad6<\/h4>\n\n\n\n<p>\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3001\u69cb\u6210\u3001\u57fa\u672c\u6982\u5ff5\u3001\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u306e\u4f7f\u7528\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u5316\u3055\u308c\u305f\u30c6\u30b9\u30c8\u3001\u30de\u30fc\u30ad\u30f3\u30b0\u3068\u30e9\u30d9\u30eb\u4ed8\u3051\u3001\u4f8b\u5916\u306e\u51e6\u7406\u3001\u9ad8\u5ea6\u306a\u30c8\u30d4\u30c3\u30af\u3001\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u306a\u3069\u3001pytest\u306e\u57fa\u672c\u3092\u7fd2\u5f97\u3057\u3066\u3044\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u3053\u306e\u77e5\u8b58\u306f\u3001Python\u30c6\u30b9\u30c8\u306e\u5206\u91ce\u3067\u3055\u3089\u306b\u958b\u767a\u3059\u308b\u305f\u3081\u306e\u5f37\u56fa\u306a\u57fa\u76e4\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u305d\u306e\u4ed6\u306e\u5b66\u7fd2\u30ea\u30bd\u30fc\u30b9<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/strong>: pytest&nbsp;<a href=\"https:\/\/docs.pytest.org\/en\/latest\/\">\u306e\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u306f\u3001\u6700\u3082\u6a29\u5a01\u306e\u3042\u308b\u5305\u62ec\u7684\u306a\u30ea\u30bd\u30fc\u30b9\u3067\u3059\u3002<\/li>\n\n\n\n<li>\u30aa\u30f3\u30e9\u30a4\u30f3\u30b3\u30fc\u30b9\u3068\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb:Udemy\u3001Coursera\u3001YouTube\u306a\u3069\u306eWeb\u30b5\u30a4\u30c8\u3067\u306f\u3001\u591a\u6570\u306epytest<strong>\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3068\u30b3\u30fc\u30b9<\/strong>\u3092\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u3068\u30d5\u30a9\u30fc\u30e9\u30e0<\/strong>:<a href=\"https:\/\/stackoverflow.com\/questions\/tagged\/pytest\">\u30b9\u30bf\u30c3\u30af\u30aa\u30fc\u30d0\u30fc\u30d5\u30ed\u30fc<\/a>\u3068<a href=\"https:\/\/www.reddit.com\/r\/pytest\/\">Reddit<\/a>\u306f\u3001\u554f\u984c\u3092\u89e3\u6c7a\u3057\u3001\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3092\u5b66\u3076\u306e\u306b\u6700\u9069\u306a\u5834\u6240\u3067\u3059\u3002<\/li>\n\n\n\n<li><strong>\u66f8\u7c4d<\/strong>: Python \u306e\u30c6\u30b9\u30c8\u3068 pytest \u306b\u95a2\u3059\u308b\u66f8\u7c4d\u304c\u3044\u304f\u3064\u304b\u3042\u308a\u3001\u4f8b\u3048\u3070 &#8220;Python Testing with pytest&#8221; \u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u30d7\u30ed\u30b8\u30a7\u30af\u30c8: pytest \u3092\u4f7f\u7528\u3057\u3066\u5b9f\u8df5\u7684\u306a\u7d4c\u9a13\u3092\u7a4d\u3080 GitHub \u4e0a\u306e\u3044\u304f\u3064\u304b\u306e\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9<strong>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8<\/strong>\u306b\u53c2\u52a0\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30d6\u30ed\u30b0<\/strong>\u3068\u8a18\u4e8b: \u591a\u304f\u306e\u958b\u767a\u8005\u3084\u30c6\u30b9\u30c8\u30a8\u30f3\u30b8\u30cb\u30a2\u306f\u3001pytest \u306b\u95a2\u3059\u308b\u9ad8\u54c1\u8cea\u306e\u8a18\u4e8b\u3092\u30d6\u30ed\u30b0\u3084 Medium \u3067\u516c\u958b\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u30ef\u30fc\u30af\u30b7\u30e7\u30c3\u30d7\u3068\u30bb\u30df\u30ca\u30fc:pytest\u95a2\u9023\u306e\u30ef\u30fc\u30af\u30b7\u30e7\u30c3\u30d7\u3084\u30ef\u30fc\u30af\u30b7\u30e7\u30c3\u30d7\u306b\u6642\u3005\u53c2\u52a0\u3057\u3066\u3001\u77e5\u8b58<strong>\u3068<\/strong>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u5e83\u3052\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u6b21\u306b<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u7df4\u7fd2:<\/strong>\u5b66\u3076\u305f\u3081\u306e\u6700\u826f\u306e\u65b9\u6cd5\u306f\u305d\u308c\u3092\u3059\u308b\u3053\u3068\u3067\u3059\u3002 \u5b66\u3093\u3060\u3053\u3068\u3092\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u5b9f\u88c5\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n\n\n\n<li><strong>\u7d99\u7d9a\u7684\u306a\u5b66\u7fd2<\/strong>:\u30c6\u30b9\u30c8\u306f\u6025\u901f\u306b\u9032\u5316\u3057\u3066\u3044\u308b\u5206\u91ce\u3067\u3059\u3002 \u95a2\u9023\u3059\u308b\u30cb\u30e5\u30fc\u30b9\u30d5\u30a3\u30fc\u30c9\u3084\u30bd\u30fc\u30b7\u30e3\u30eb\u30e1\u30c7\u30a3\u30a2\u30c1\u30e3\u30cd\u30eb\u3092\u8cfc\u8aad\u3057\u3066\u3001\u6700\u65b0\u306e\u72b6\u614b\u3092\u4fdd\u3061\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u8ca2\u732e\u3059\u308b<\/strong>: pytest \u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u3078\u306e\u8ca2\u732e\u306f\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u66f8\u304f\u304b\u3001\u554f\u984c\u3092\u89e3\u6c7a\u3057\u3066\u65b0\u3057\u3044\u6a5f\u80fd\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3067\u691c\u8a0e\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3053\u306e\u6700\u5f8c\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u5168\u4f53\u306e\u5185\u5bb9\u3092\u8981\u7d04\u3059\u308b\u3060\u3051\u3067\u306a\u304f\u3001\u8aad\u8005\u304c\u5b66\u7fd2\u306e\u65c5\u3092\u7d9a\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u3001\u3055\u307e\u3056\u307e\u306a\u65b9\u6cd5\u3068\u30ea\u30bd\u30fc\u30b9\u3082\u63d0\u4f9b\u3057\u307e\u3059\u3002 \u3046\u307e\u304f\u3044\u3051\u3070\u3001\u3053\u308c\u306f\u3042\u306a\u305f\u306epytest\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u306b\u8cb4\u91cd\u306a\u60c5\u5831\u3092\u63d0\u4f9b\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>pytest\u306e\u4e2d\u56fd\u8a9e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u3084\u308a &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false,"footnotes":""},"categories":[23],"tags":[],"class_list":["post-2971","post","type-post","status-publish","format-standard","hentry","category-material"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/edu.ujhb.org\/index.php?rest_route=\/wp\/v2\/posts\/2971","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/edu.ujhb.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/edu.ujhb.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/edu.ujhb.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/edu.ujhb.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2971"}],"version-history":[{"count":1,"href":"https:\/\/edu.ujhb.org\/index.php?rest_route=\/wp\/v2\/posts\/2971\/revisions"}],"predecessor-version":[{"id":2972,"href":"https:\/\/edu.ujhb.org\/index.php?rest_route=\/wp\/v2\/posts\/2971\/revisions\/2972"}],"wp:attachment":[{"href":"https:\/\/edu.ujhb.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/edu.ujhb.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/edu.ujhb.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}