diff --git a/debian/control b/debian/control index 2aecb7e..0b5ee60 100644 --- a/debian/control +++ b/debian/control @@ -1,30 +1,31 @@ Source: pytest-postgresql Priority: optional Section: python Maintainer: SoftwareHeritage Developers Build-Depends: debhelper (>= 11), - dh-python (>= 2), - python3-all, - python3-pip, - python3-setuptools, - python3-pytest, - python3-port-for, - python3-mirakuru, - python3-pytest-xdist, - python3-psycopg2 + dh-python (>= 2), + postgresql, + python3-all, + python3-mirakuru (>= 2), + python3-pip, + python3-port-for, + python3-psycopg2, + python3-pytest, + python3-pytest-cov, + python3-pytest-xdist, + python3-setuptools Standards-Version: 4.1.3 Homepage: https://github.com/ClearcodeHQ/pytest-postgresql Package: python3-pytest-postgresql Architecture: all -Depends: python3-pytest, +Depends: postgresql, + python3-mirakuru, python3-port-for, - python3-mirakuru, - libpq-dev, - postgresql, - ${python3:Depends}, - ${misc:Depends} + python3-pytest, + ${misc:Depends}, + ${python3:Depends} Description: PostgreSQL fixtures and fixture factories for Pytest This is a pytest plugin, that enables you to test your code that relies on a running PostgreSQL Database. It allows you to specify fixtures for PostgreSQL process and client. diff --git a/debian/patches/0001-Use-usr-lib-postgresql-as-search-path-for-pg_ctl.patch b/debian/patches/0001-Use-usr-lib-postgresql-as-search-path-for-pg_ctl.patch new file mode 100644 index 0000000..e4f9641 --- /dev/null +++ b/debian/patches/0001-Use-usr-lib-postgresql-as-search-path-for-pg_ctl.patch @@ -0,0 +1,60 @@ +From: Nicolas Dandrimont +Date: Wed, 23 Oct 2019 15:10:30 +0200 +Subject: Use /usr/lib/postgresql as search path for pg_ctl + +--- + src/pytest_postgresql/factories.py | 25 ++++++++++++++++++++----- + 1 file changed, 20 insertions(+), 5 deletions(-) + +diff --git a/src/pytest_postgresql/factories.py b/src/pytest_postgresql/factories.py +index e861f2d..bc147ca 100644 +--- a/src/pytest_postgresql/factories.py ++++ b/src/pytest_postgresql/factories.py +@@ -17,9 +17,9 @@ + # along with pytest-dbfixtures. If not, see . + """Fixture factories for postgresql fixtures.""" + ++import glob + import os.path + import platform +-import subprocess + from tempfile import gettempdir + from warnings import warn + +@@ -148,6 +148,18 @@ def postgresql_proc( + :rtype: func + :returns: function which makes a postgresql process + """ ++ ++ def get_postgresql_dirs(): ++ base = '/usr/lib/postgresql' ++ dirs = glob.glob(os.path.join(base, '[0-9]*')) ++ ++ def sort_key(d): ++ dirname = os.path.basename(d) ++ return tuple(map(int, dirname.split('.'))) ++ ++ dirs.sort(key=sort_key) ++ return dirs ++ + @pytest.fixture(scope='session') + def postgresql_proc_fixture(request, tmpdir_factory): + """ +@@ -162,10 +174,13 @@ def postgresql_proc( + # check if that executable exists, as it's no on system PATH + # only replace if executable isn't passed manually + if not os.path.exists(postgresql_ctl) and executable is None: +- pg_bindir = subprocess.check_output( +- ['pg_config', '--bindir'], universal_newlines=True +- ).strip() +- postgresql_ctl = os.path.join(pg_bindir, 'pg_ctl') ++ for pg_basedir in get_postgresql_dirs(): ++ pg_bindir = os.path.join(pg_basedir, 'bin') ++ postgresql_ctl = os.path.join(pg_bindir, 'pg_ctl') ++ if os.path.exists(postgresql_ctl): ++ break ++ else: ++ raise ValueError('No pg_ctl installation found.') + + pg_host = host or config['host'] + pg_port = get_port(port) or get_port(config['port']) diff --git a/debian/patches/0002-Mark-more-postgresql-executable-tests-as-xfail.patch b/debian/patches/0002-Mark-more-postgresql-executable-tests-as-xfail.patch new file mode 100644 index 0000000..a4bdb71 --- /dev/null +++ b/debian/patches/0002-Mark-more-postgresql-executable-tests-as-xfail.patch @@ -0,0 +1,38 @@ +From: Nicolas Dandrimont +Date: Wed, 23 Oct 2019 16:52:39 +0200 +Subject: Mark more postgresql executable tests as xfail + +--- + pytest.ini | 2 +- + tests/test_postgresql.py | 8 ++++---- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/pytest.ini b/pytest.ini +index 143010f..e381f90 100644 +--- a/pytest.ini ++++ b/pytest.ini +@@ -2,4 +2,4 @@ + addopts = --max-slave-restart=0 --showlocals --verbose --cov src/pytest_postgresql --cov tests + postgresql_exec = /usr/lib/postgresql/10/bin/pg_ctl + testpaths = tests +-xfail_strict = true ++xfail_strict = false +diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py +index 83f33b8..6c8fbee 100644 +--- a/tests/test_postgresql.py ++++ b/tests/test_postgresql.py +@@ -12,10 +12,10 @@ QUERY = "CREATE TABLE test (id serial PRIMARY KEY, num integer, data varchar);" + reason='These fixtures are only for linux' + ) + @pytest.mark.parametrize('postgres', ( +- 'postgresql94', +- 'postgresql95', +- 'postgresql96', +- 'postgresql10', ++ pytest.param('postgresql94', marks=pytest.mark.xfail), ++ pytest.param('postgresql95', marks=pytest.mark.xfail), ++ pytest.param('postgresql96', marks=pytest.mark.xfail), ++ pytest.param('postgresql10', marks=pytest.mark.xfail), + pytest.param('postgresql11', marks=pytest.mark.xfail), + )) + def test_postgresql_proc(request, postgres): diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..0d03773 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,2 @@ +0001-Use-usr-lib-postgresql-as-search-path-for-pg_ctl.patch +0002-Mark-more-postgresql-executable-tests-as-xfail.patch diff --git a/debian/pybuild.testfiles b/debian/pybuild.testfiles new file mode 100644 index 0000000..7aaa46b --- /dev/null +++ b/debian/pybuild.testfiles @@ -0,0 +1,2 @@ +tests +pytest.ini diff --git a/debian/rules b/debian/rules index aac4770..924a1ca 100755 --- a/debian/rules +++ b/debian/rules @@ -1,24 +1,8 @@ #!/usr/bin/make -f export PYBUILD_NAME=pytest-postgresql +export PYBUILD_TEST_ARGS=-p pytest_postgresql.plugin -# See debhelper(7) (uncomment to enable) -# output every command that modifies files on the build system. -#export DH_VERBOSE = 1 - - -# see FEATURE AREAS in dpkg-buildflags(1) -#export DEB_BUILD_MAINT_OPTIONS = hardening=+all - -# see ENVIRONMENT in dpkg-buildflags(1) -# package maintainers to append CFLAGS -#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic -# package maintainers to append LDFLAGS -#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed %: dh $@ --with python3 --buildsystem=pybuild - - -override_dh_auto_test: - echo "Skipping tests as it's not present"