Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sIF8n-00E8Y5-2m for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Jun 2024 22:11:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sIF8j-006j4W-79 for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Jun 2024 22:11:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sIF8i-006j0K-ST for pgsql-hackers@lists.postgresql.org; Fri, 14 Jun 2024 22:11:21 +0000 Received: from mail-yw1-f170.google.com ([209.85.128.170]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sIF8f-001LCN-3n for pgsql-hackers@postgresql.org; Fri, 14 Jun 2024 22:11:20 +0000 Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-633629c3471so3821197b3.1 for ; Fri, 14 Jun 2024 15:11:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718403076; x=1719007876; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ygojjsJrSG7KJ7VBJiE96uXNT00XYnlkQGDnx53eOlY=; b=v0049HyYrF42H3oYNYK4JkcLm5fae8ltrsVUh5DG4ekNFaCJhsB1/71pvD5HmSmU2r IYcScYPfbisoSq0uRjraLdkwSjZx1ocI2KTURk8isT60In4+lTl2o/a7t301Vxt0fXBG x4jSDkJuvePoOuyis+7diuCC5HeY9Qv7hY2fin+CnX+7zkSJswBwY5usqBo1gGe4UWyi wQNjX4Kc40P/erp+P5TYEaxmalttLruM5x9Bd82CPvLuBbbPPUfOUDChqgVxGCtrHURk CwZ5sSMnNdQI5OKysSjwfq3x8S8i5u4IYZZLn4mS0fUJFwzhQMP9EmVGDBKTvjmoyWcA 1Dgw== X-Forwarded-Encrypted: i=1; AJvYcCWFWLUlGmMEJ5bIG4MN6aB5g28HDjvYFeKF0LQXObU2UlRECKImahvFx4wdUYJk4Fu5gRq+nTYyY1xD2yMP4xlthEQmXmIAoxcufkWm X-Gm-Message-State: AOJu0YyBrpOf7FTqOvvte7TEj/mY3XMqC7w2RWgSVrG+9f283wxFTTnG 5mi3oG/FBVie9AhH1bkc1c+2YTCmivUrfjt3fr4FHXB2WzBXblh8oX0PCdWYNpdxX3rTuNMS6JC WFyrvVXFkENu0MVvKpQ+wPcZ6B8M2A9PH4/tw/Q== X-Google-Smtp-Source: AGHT+IE69X/av6zRgEwUy+10dj9WF28JwfDMmkU+30+6tsUq8e/LR7Hy3UQzSEOv7QfzJQPu7QCtiL2yuD/rkhPSENk= X-Received: by 2002:a05:690c:dd2:b0:62f:5c0d:afff with SMTP id 00721157ae682-6321f0abd33mr51293587b3.0.1718403076096; Fri, 14 Jun 2024 15:11:16 -0700 (PDT) MIME-Version: 1.0 References: <20240610200411.byj6sv2vpgol6wcf@awork3.anarazel.de> <20240612155040.u6cvatdb5tiwcxci@awork3.anarazel.de> <2302192.1718380169@sss.pgh.pa.us> In-Reply-To: <2302192.1718380169@sss.pgh.pa.us> From: Jelte Fennema-Nio Date: Sat, 15 Jun 2024 00:11:04 +0200 Message-ID: Subject: Re: RFC: adding pytest as a supported test framework To: Tom Lane Cc: Robert Haas , Jacob Champion , Daniel Gustafsson , Andres Freund , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 14 Jun 2024 at 17:49, Tom Lane wrote: > But what I'd really like to see is some comparison of the > language-provided testing facilities that we're proposing > to depend on. Why is pytest (or whatever) better than Test::More? Some advantages of pytest over Test::More: 1. It's much easier to debug failing tests using the output that pytest gives. A good example of this is on pytest its homepage[1] (i.e. it shows the value given to the call to inc in the error) 2. No need to remember a specific comparison DSL (is/isnt/is_deeply/like/ok/cmp_ok/isa_ok), just put assert in front of a boolean expression and your output is great (if you want to add a message too for clarity you can use: assert a =3D=3D b, "the world is ending") 3. Very easy to postgres log files on stderr/stdout when a test fails. This might be possible/easy with Perl too, but we currently don't do that. So right now for many failures you're forced to traverse the build/testrun/... directory tree to find the logs. 4. Pytest has autodiscovery of test files and functions, so we probably wouldn't have to specify all of the exact test files anymore in the meson.build files. Regarding 2, there are ~150 checks that are using a suboptimal way of testing for a comparison. Mostly a lot that could use "like(..., ...)" instead of "ok(... ~=3D ...)" =E2=9D=AF grep '\bok(.*=3D' **.pl | wc -l 151 [1]: https://docs.pytest.org/en/8.2.x/#a-quick-example