Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fLqs0-0000FK-8P for pgadmin-hackers@arkaria.postgresql.org; Thu, 24 May 2018 14:05:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fLqrw-0002yO-Qu for pgadmin-hackers@arkaria.postgresql.org; Thu, 24 May 2018 14:05:28 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fLqrw-0002y3-Dn for pgadmin-hackers@lists.postgresql.org; Thu, 24 May 2018 14:05:28 +0000 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fLqro-0000jH-UN for pgadmin-hackers@postgresql.org; Thu, 24 May 2018 14:05:27 +0000 Received: by mail-wr0-x22c.google.com with SMTP id k5-v6so3379672wrn.3 for ; Thu, 24 May 2018 07:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgadmin-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Z4r1LdZlh0j2ckPB+hq9+fwwZKbetgQLopEo4DKA5EQ=; b=gyL55I6MDnlEY/N/9kIrIy4+s0sam6hhNUl5ONWdJgNzIjtPIz8r6FCfpUWBzWQ20H dLrhF1c/YxCRa2OPlE2Zuvts1q/cqhveGD7qRX9Ukm0LlBRg3c1VGsGPWhKkiVMin6Zw vILDQAKXHKb1ESOgWaGEGpVKJ0O7ol6U572uPmU/sJc6PL9ZpZoTlFOefQFkku3PGGNq GzQV/7uWCEtCu2bi/g4dt6GDRxbHka/cYm+PZf0fVaik3lkdS5/DAH5uGH8ynAcxE4PY HB+XK+rbCKqQ6FcmbDGT1exOu1JufxpLAebL292i7N5rBXMxyVTnvthnT6tvKrpq2eFc I6mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Z4r1LdZlh0j2ckPB+hq9+fwwZKbetgQLopEo4DKA5EQ=; b=RSKJvTnc9AvxPigNO5/d5bEdY3y8nHvwiQLsAH2z5BxxgJNRLSFaw1OiVT4Eb0F5hB xbItJL4hqtATB9NW21A+pm+DpSBbeBuurE+I8UcBvlWhECT/KBB5KKfvdLueDogWGbGI XtjC81AzP0S2d5/iaFxTu6wDpLA1z6PEFFwjn8OLK4oGQU+8Afqb9HgV0Xj/x8dAJL0l cyWCFm4lFmL5NIPUQ9WrEGb/8nbpaKFyGfIn3yRYK5jPBNXXouPxnLc3IDphDFexG75H rpP4puSNHRno66PBhrdHWJTBOVHczuKFh3GFewIf9iBvO5Cb1jUya7mbLvz5KxHVNQl6 JrrA== X-Gm-Message-State: ALKqPwc7cbTG48f3BN93hGveZP0zJB8T0wwEr1MYy270IQsZfxaZylE+ QRhz887oLSy3F5zjP5W3muqesZizidt45Bh78FI5Eg== X-Google-Smtp-Source: AB8JxZqLYcHeXTmRPzcaM5ov9/zLkt2mkh39tOMvy6RXDnQRJ00WC/CqbUOL9pE5bM8/kbnkvN1vHiofcozfBMyRN1g= X-Received: by 2002:adf:df81:: with SMTP id z1-v6mr7217043wrl.49.1527170717572; Thu, 24 May 2018 07:05:17 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:55c2:0:0:0:0:0 with HTTP; Thu, 24 May 2018 07:05:16 -0700 (PDT) In-Reply-To: References: From: Dave Page Date: Thu, 24 May 2018 15:05:16 +0100 Message-ID: Subject: Re: [pgadmin4][patch] Use pytest test runner for unit tests To: Anthony Emengo Cc: pgadmin-hackers Content-Type: multipart/alternative; boundary="00000000000021f4d0056cf42409" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --00000000000021f4d0056cf42409 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi On Wed, May 23, 2018 at 10:48 PM, Anthony Emengo wrote= : > Hey all, > > Attached is a rather large patch that attempts to introduce the Pytest > test runner and Grappah test matcher into our code base. The patch replac= es > all of the previous python unit tests from the previous design. This is a > follow-up from our previous proof of concept and discussion around the > idiosyncrasies of our existing test suite. > > We are motivated to submit this change for the following reasons: > > 1. Having a highly customized test suite increases the learning curve > towards contributing to the code base. Pytest is a mature stable python > test framework that outside developers are more likely to be familiar wit= h. > 2. Pytest supports a lot of the features that we've built for our > use-cases - out of the box, and with extensive documentation on the matte= r. > 3. The lack of ability to run tests individually has become a pain point. > Especially when it comes to debugging long running feature tests. > > Test can be ran with the following command: > > yarn test:unit > > =E2=80=8B > Please let us know what you think and if there are any issues! > (pgadmin4) piranha:web dpage$ yarn test:unit yarn run v1.3.2 $ yarn run linter && pytest -q pgadmin $ yarn eslint --no-eslintrc -c .eslintrc.js --ext .js --ext .jsx . $ /Users/dpage/git/pgadmin4/web/node_modules/.bin/eslint --no-eslintrc -c .eslintrc.js --ext .js --ext .jsx . Traceback (most recent call last): File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/_pytest/con= fig.py", line 371, in _importconftest mod =3D conftestpath.pyimport() File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/py/_path/lo= cal.py", line 668, in pyimport __import__(modname) File "/Users/dpage/git/pgadmin4/web/pgadmin/__init__.py", line 29, in from pgadmin.model import db, Role, Server, ServerGroup, \ ImportError: No module named pgadmin.model ERROR: could not load /Users/dpage/git/pgadmin4/web/pgadmin/conftest.py error Command failed with exit code 4. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. > > *Note: *The feature tests are not yet completed. We expect our CI to fail > as a result of this patch. We will complete this step soon in a follow-up > patch! > > https://docs.pytest.org/en/latest/ > https://github.com/grappa-py/grappa > Please don't forget to update the README and top level Makefile as well! I'll probably have to tweak my Windows CI jobs, but the Linux/Mac ones all use the Makefile (which is also hard-coded into my fingers)! --=20 Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company --00000000000021f4d0056cf42409 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

On Wed, May 23, 2018 at 10:48 PM, Anthony Emengo &l= t;aemengo@pivotal.i= o> wrote:
= Hey all,

Attached is a rather large patch that attempts = to introduce the Pytest test runner and Grappah test matcher into our code = base. The patch replaces all of the previous python unit tests from the pre= vious design. This is a follow-up from our previous proof of concept and di= scussion around the idiosyncrasies of our existing test suite.
We are motivated to submit this change for the following reaso= ns:

1. Having a highly customized test suite incre= ases the learning curve towards contributing to the code base. Pytest is a = mature stable python test framework that outside developers are more likely= to be familiar with.
2. Pytest supports a lot of the features th= at we've built for our use-cases - out of the box, and with extensive d= ocumentation on the matter.=C2=A0
3. The lack of ability to run t= ests individually has become a pain point. Especially when it comes to debu= gging long running feature tests.=C2=A0 =C2=A0 =C2=A0=C2=A0

<= /div>
Test can be ran with the following command:
yarn test:unit
=E2=80=8B
Please let us know what you think and if there are any = issues!

(pgadmin4) piranha:web dpage$ yarn test:unit

yarn run v1.3.2

$ yarn run linter && pytest -q pgadmin

$ yarn eslint --no-eslintrc -c .eslintrc.js --ex= t .js --ext .jsx .

$ /Users/dpage/git/pgadmin4/web/node_modules/.bi= n/eslint --no-eslintrc -c .eslintrc.js --ext .js --ext .jsx .

Traceback (most recent call last):

=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa= ges/_pytest/config.py", line 371, in _importconftest

=C2=A0 = =C2=A0 mod =3D conftestpath.pyimport()

=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa= ges/py/_path/local.py", line 668, in pyimport

=C2=A0 = =C2=A0 __import__(modname)

=C2=A0 File "/Users/dpage/git/pgadmin4/web/pgadmin/__init__.py", li= ne 29, in <module>

=C2=A0 = =C2=A0 from pgadmin.model import db, Role, Server, ServerGroup, \

ImportError: No module named pgadmin.model

ERROR: could not load /Users/dpage/git/pgadmin4/web/p= gadmin/conftest.py


error Command failed w= ith exit code 4.

info Visit https://y= arnpkg.com/en/docs/cli/run for documentation about this comma= nd.



=C2=A0

Note: The feature tests are not y= et completed. We expect our CI to fail as a result of this patch. We will c= omplete this step soon in a follow-up patch!=C2=A0

https://d= ocs.pytest.org/en/latest/

=C2=A0Please don'= t forget to update the README and top level Makefile as well! I'll prob= ably have to tweak my Windows CI jobs, but the Linux/Mac ones all use the M= akefile (which is also hard-coded into my fingers)!

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB= UK: http://www.e= nterprisedb.com
The Enterprise PostgreSQL Company
--00000000000021f4d0056cf42409--