1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 pytestCheckHook,
7 pytest-cov-stub,
8 setuptools,
9 mirakuru,
10 port-for,
11 psycopg,
12 pytest,
13 postgresql,
14}:
15
16buildPythonPackage rec {
17 pname = "pytest-postgresql";
18 version = "6.0.0";
19 pyproject = true;
20
21 src = fetchFromGitHub {
22 owner = "ClearcodeHQ";
23 repo = "pytest-postgresql";
24 tag = "v${version}";
25 hash = "sha256-6D9QNcfq518ORQDYCH5G+LLJ7tVWPFwB6ylZR3LOZ5g=";
26 };
27
28 postPatch = ''
29 substituteInPlace pyproject.toml \
30 --replace-fail "--max-worker-restart=0" ""
31 sed -i 's#/usr/lib/postgresql/.*/bin/pg_ctl#${postgresql}/bin/pg_ctl#' pytest_postgresql/plugin.py
32 '';
33
34 buildInputs = [ pytest ];
35
36 dependencies = [
37 mirakuru
38 port-for
39 psycopg
40 setuptools # requires 'pkg_resources' at runtime
41 ];
42
43 nativeCheckInputs = [
44 postgresql
45 pytestCheckHook
46 pytest-cov-stub
47 ];
48 pytestFlagsArray = [
49 "-p"
50 "no:postgresql"
51 ];
52 disabledTestPaths = [ "tests/docker/test_noproc_docker.py" ]; # requires Docker
53 disabledTests = [
54 # permissions issue running pg as Nixbld user
55 "test_executor_init_with_password"
56 # "ValueError: Pytest terminal summary report not found"
57 "test_postgres_loader_in_cli"
58 "test_postgres_options_config_in_cli"
59 "test_postgres_options_config_in_ini"
60 ];
61 pythonImportsCheck = [
62 "pytest_postgresql"
63 "pytest_postgresql.executor"
64 ];
65
66 # Can't reliably run checkPhase on darwin because of nix bug, see:
67 # https://github.com/NixOS/nixpkgs/issues/371242
68 doCheck = !stdenv.buildPlatform.isDarwin;
69
70 meta = {
71 homepage = "https://pypi.python.org/pypi/pytest-postgresql";
72 description = "Pytest plugin that enables you to test code on a temporary PostgreSQL database";
73 changelog = "https://github.com/ClearcodeHQ/pytest-postgresql/blob/v${version}/CHANGES.rst";
74 license = lib.licenses.lgpl3Plus;
75 maintainers = with lib.maintainers; [ bcdarwin ];
76 };
77}