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 1sJZw8-005gwP-I4 for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jun 2024 14:35:52 +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 1sJZw6-00ELhU-9u for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jun 2024 14:35:51 +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 1sJZw5-00ELf0-Rq for pgsql-hackers@lists.postgresql.org; Tue, 18 Jun 2024 14:35:50 +0000 Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sJZw3-001vIN-9C for pgsql-hackers@postgresql.org; Tue, 18 Jun 2024 14:35:48 +0000 Received: by mail-qv1-xf34.google.com with SMTP id 6a1803df08f44-6b4ffc2a7abso2024376d6.1 for ; Tue, 18 Jun 2024 07:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1718721346; x=1719326146; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=rTNXnbYN/EfRlPkFSwqASC++jKZvhhNliaMnYRSXg04=; b=cfFhAUDHgC3shkOtu8NgozaL54lyuj2Yhcde7Xj1TO6heSv+QDMQPZ20RWqVbLVs2K 9PsdN1HJF9VEyQ4z4cfhIWE4K4E8ejcPjlm6lOdSltUk/cDF75BvBKaoo4c4NlDFrmQu eapyggfRtYW5bMg0WJ9ZdiqEPWhaa+QpsnNRIvMdW15oOUdusRT1BJZt8l0Z92cm0f2W 5CRTBAjnenoQLgYtcplKuMR9WOi27PwWEX240sG3uh/dO7VLgycGr6daU3sFmbkg8cRs UIWU3OZgvvViTlhXTrt++XA8+gTSxrgexapjaX24b2yEdQNqqnr25CBRYCEeY/ncflCt Au6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718721346; x=1719326146; 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=rTNXnbYN/EfRlPkFSwqASC++jKZvhhNliaMnYRSXg04=; b=AaM+8ycv0EtNxpoYmkt7yXT+pCQrqygDb6nll8e2nEBGXkARmZDW+R2+Yvwd6nlyG6 bCi2yA43o8141POuLVcrjW4TqvXOT/XMZYS4SlnqLNtj1eTvYnApr09EUI+laUqhuUUl t1SvVnUjkPtS5hZ/CdHxum05OM2/+A+Thv34YUdOzqRz8fOarfcT/qd/ZPOyYmIoqzBx 59ICqdcttnwh/808eV7/iPMakTjUOKmQPPrCKd4bOWYzcyogNFaB8l3CcRfzz/E/otuT LKgkARXFeOvYgvtOfjk6aX5Ibr0L/adxc5EJphH3ubRtEV+lritIrUobH5lgSerf2ziq /xVw== X-Forwarded-Encrypted: i=1; AJvYcCXjsUVa4R7SXQsmQIXln8z+EfaF970VhNq+tThSkJcpuHFlGXkvOgZA4x0gbSDiB6BpATG+XLNKt40B6t7kuOaBnAgq2jQrqHbeXlYP X-Gm-Message-State: AOJu0YycstNm4ae9mdpLhITHHF3BeNpYAVAHVcPtEepRYiPSbkb93pEZ lt/v/E+W4RIy68XrcenGH42Ow2F0/wOoQKWgZlur08OEese/JX6WYEgpd4uWZaq4Ij93S1AwaJx w2RkmBlxJEGPeV/J78QRqOQr9CbgOy7DM1YD1 X-Google-Smtp-Source: AGHT+IEeHrdvh0Pv2ZQICgteWSCFcnApz++Tx1/T6cVJ+zfqaAHVewIkunJr5dRMp7F/lOUU5tkOYVLasVgoN2H7sRM= X-Received: by 2002:ad4:5ccf:0:b0:6ab:9c77:c32c with SMTP id 6a1803df08f44-6b2e230dcbfmr52662856d6.10.1718721346449; Tue, 18 Jun 2024 07:35:46 -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: Jacob Champion Date: Tue, 18 Jun 2024 07:35:35 -0700 Message-ID: Subject: Re: RFC: adding pytest as a supported test framework To: Tom Lane Cc: Robert Haas , Jelte Fennema-Nio , 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, Jun 14, 2024 at 8:49=E2=80=AFAM Tom Lane wrote: > I think that's an oversimplified analysis. Sure, the languages are > both Turing-complete, but for our purposes here they are both simply > glue languages around some set of testing facilities. Some of those > facilities will be provided by the base languages (plus whatever > extension modules we choose to require) and some by code we write. > The overall experience of writing tests will be determined by the > testing facilities far more than by the language used for glue. +1. As an example, the more extensive (and high-quality) a language's standard library, the more tests you'll be able to write. Convincing committers to adopt a new third-party dependency is hard (for good reason); the strength of the standard library should be considered as a point of technical comparison. > That being the case, I do agree with your point that Python > equivalents to most of PostgreSQL::Test will need to be built up PDQ. > Maybe they can be better than the originals, in features or ease of > use, but "not there at all" is not better. There's a wide gulf between "not there at all" and "reimplement it all as a prerequisite for v1" as Robert proposed. I'm arguing for a middle ground. > 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? People are focusing a lot on failure reporting, and I agree with them, but I did try to include more than just that in my OP. I'll requote what I personally think is the #1 killer feature of pytest, which prove and Test::More appear to be unable to accomplish on their own: configurable isolation of tests from each other via fixtures [1]. Problem 1 (rerun failing tests): One architectural roadblock to this in our Test::More suite is that tests depend on setup that's done by previous tests. pytest allows you to declare each test's setup requirements via pytest fixtures, letting the test runner build up the world exactly as it needs to be for a single isolated test. These fixtures may be given a "scope" so that multiple tests may share the same setup for performance or other reasons. When I'm doing red-to-green feature development (e.g. OAuth) or green-to-green refactoring (e.g. replacement of libiddawc with libcurl in OAuth), quick cycle time and reduction of noise is extremely important. I want to be able to rerun just the single red test I care about before moving on. (Tests may additionally be organized with custom attributes. My OAuth suite contains tests that must run slowly due to mandatory timeouts; I've marked them as slow, and they can be easily skipped from the test runner.) 2. The ability to break into a test case with the built-in debugger [2] is also fantastic for quick red-green work. Much better than print() statements. (Along similar lines, even the ability to use Python's built-in REPL increases velocity. Python users understand that they can execute `python3` and be dropped into a sandbox to try out syntax or some unfamiliar library. Searching for how to do this in Perl results in a handful of custom-built scripts; people here may know which to use as a Perl monk, sure, but the point is to make it easy for newcomers to write tests.) > I also wonder about integration of python-based testing with what > we already have. A significant part of what you called the meson > work had to do with persuading pg_regress, isolationtester, etc > to output test results in the common format established by TAP. > Am I right in guessing that pytest will have nothing to do with that? Andres covered this pretty well. I will note that I had problems with pytest-tap itself [3], and I'm unclear whether that represents a bug in pytest-tap or a bug in pytest. Thanks, --Jacob [1] https://docs.pytest.org/en/stable/how-to/fixtures.html [2] https://docs.pytest.org/en/stable/how-to/failures.html [3] https://github.com/python-tap/pytest-tap/issues/30