Re: [pgadmin4][patch] Use pytest test runner for unit tests - Mailing list pgadmin-hackers

From Dave Page
Subject Re: [pgadmin4][patch] Use pytest test runner for unit tests
Date
Msg-id CA+OCxoyhMprhxCMss5oESTMcVVnVcyBOP_AuntNyZsRyeZu5rg@mail.gmail.com
Whole thread Raw
In response to [pgadmin4][patch] Use pytest test runner for unit tests  (Anthony Emengo <aemengo@pivotal.io>)
Responses Re: [pgadmin4][patch] Use pytest test runner for unit tests
List pgadmin-hackers
Hi

On Wed, May 23, 2018 at 10:48 PM, Anthony Emengo <aemengo@pivotal.io> 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 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 with.
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 matter. 
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
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/config.py", line 371, in _importconftest

    mod = conftestpath.pyimport()

  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/py/_path/local.py", line 668, in pyimport

    __import__(modname)

  File "/Users/dpage/git/pgadmin4/web/pgadmin/__init__.py", line 29, in <module>

    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! 


 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)!

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

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

pgadmin-hackers by date:

Previous
From: Dave Page
Date:
Subject: Re: Implement geospatial data viewer in pgAdmin4 for PostGIS
Next
From: Joao De Almeida Pereira
Date:
Subject: Re: [pgadmin4][patch] Initial patch to decouple from ACI Tree