1{ lib, buildPythonPackage, fetchFromGitHub, runtimeShell,
2 nose, dbus, dbus-python, pygobject3,
3 which, pyflakes, pycodestyle, bluez, networkmanager
4}:
5
6buildPythonPackage rec {
7 pname = "python-dbusmock";
8 version = "0.19";
9
10 src = fetchFromGitHub {
11 owner = "martinpitt";
12 repo = pname;
13 rev = version;
14 sha256 = "09j338lmrjabbd3fpajr4piz4r20sl33030szfsqfzlwrrmvkyi0";
15 };
16
17 prePatch = ''
18 substituteInPlace tests/test_code.py \
19 --replace "pyflakes3" "pyflakes" \
20 --replace "/bin/bash" "${runtimeShell}" \
21 --replace "--ignore=E124,E402,E731,W504" "--ignore=E124,E402,E731,W504,E501" # ignore long lines too
22 '';
23
24 # TODO: Get the rest of these tests running?
25 # This is a mocking library used as a check dependency for a single derivation.
26 # That derivation's tests pass. Maybe not worth the effort to fix these...
27 NOSE_EXCLUDE = lib.concatStringsSep "," [
28 "test_bluez4" # NixOS ships BlueZ5
29 # These appear to fail because they're expecting to run in an Ubuntu chroot?
30 "test_everything" # BlueZ5 OBEX
31 "test_polkitd"
32 "test_consolekit"
33 "test_api"
34 "test_logind"
35 "test_notification_daemon"
36 "test_ofono"
37 "test_gnome_screensaver"
38 "test_cli"
39 "test_timedated"
40 "test_upower"
41 # Very slow, consider disabling?
42 # "test_networkmanager"
43 ];
44
45 checkInputs = [
46 nose dbus dbus-python which pycodestyle pyflakes
47 pygobject3 bluez (lib.getOutput "test" bluez) networkmanager
48 ];
49
50 checkPhase = ''
51 runHook preCheck
52 export PATH="$PATH:${lib.getOutput "test" bluez}/test";
53 nosetests -v
54 runHook postCheck
55 '';
56
57 meta = with lib; {
58 description = "Mock D-Bus objects for tests";
59 homepage = "https://github.com/martinpitt/python-dbusmock";
60 license = licenses.lgpl3Plus;
61 maintainers = with maintainers; [ callahad ];
62 platforms = platforms.linux;
63 };
64}