summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pytest-postgresql/default.nix
blob: ad9fe91934076c35e5143160b78157b3210f2c61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  pytestCheckHook,
  pytest-cov-stub,
  setuptools,
  mirakuru,
  packaging,
  port-for,
  psycopg,
  pytest,
  postgresql,
}:

buildPythonPackage rec {
  pname = "pytest-postgresql";
  version = "7.0.2";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "dbfixtures";
    repo = "pytest-postgresql";
    tag = "v${version}";
    hash = "sha256-/EekUveW3wb8NlcKacMJpjjU7bpFvnNMpAuZ9h0sbpw=";
  };

  postPatch = ''
    sed -i 's#/usr/lib/postgresql/.*/bin/pg_ctl#${postgresql}/bin/pg_ctl#' pytest_postgresql/plugin.py
  '';

  build-system = [ setuptools ];

  buildInputs = [ pytest ];

  dependencies = [
    mirakuru
    port-for
    psycopg
    packaging
  ];

  nativeCheckInputs = [
    postgresql
    pytestCheckHook
    pytest-cov-stub
  ];
  pytestFlags = [
    "-pno:postgresql"
  ];
  disabledTestPaths = [ "tests/docker/test_noproc_docker.py" ]; # requires Docker
  disabledTests = [
    # "ValueError: Pytest terminal summary report not found"
    "test_postgres_drop_test_database"
    "test_postgres_loader_in_cli"
    "test_postgres_loader_in_ini"
    "test_postgres_options_config_in_cli"
    "test_postgres_options_config_in_ini"
    "test_postgres_port_search_count_in_cli_is_int"
    "test_postgres_port_search_count_in_ini_is_int"
  ];
  pythonImportsCheck = [
    "pytest_postgresql"
    "pytest_postgresql.executor"
  ];

  # Can't reliably run checkPhase on darwin because of nix bug, see:
  #  https://github.com/NixOS/nixpkgs/issues/371242
  doCheck = !stdenv.buildPlatform.isDarwin;

  meta = {
    homepage = "https://pypi.python.org/pypi/pytest-postgresql";
    description = "Pytest plugin that enables you to test code on a temporary PostgreSQL database";
    changelog = "https://github.com/dbfixtures/pytest-postgresql/blob/v${version}/CHANGES.rst";
    license = lib.licenses.lgpl3Plus;
    maintainers = with lib.maintainers; [ bcdarwin ];
  };
}