1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, pytestCheckHook
6, pythonOlder
7}:
8
9buildPythonPackage rec {
10 version = "5.2.4";
11 pname = "pyfakefs";
12 disabled = pythonOlder "3.5";
13
14 src = fetchPypi {
15 inherit pname version;
16 hash = "sha256-PgQPN5IIYIag3CGRsF/nCUOOFoqv4ulPzb7444WSCNg=";
17 };
18
19 postPatch = ''
20 # test doesn't work in sandbox
21 substituteInPlace pyfakefs/tests/fake_filesystem_test.py \
22 --replace "test_expand_root" "notest_expand_root"
23 substituteInPlace pyfakefs/tests/fake_os_test.py \
24 --replace "test_path_links_not_resolved" "notest_path_links_not_resolved" \
25 --replace "test_append_mode_tell_linux_windows" "notest_append_mode_tell_linux_windows"
26 '' + (lib.optionalString stdenv.isDarwin ''
27 # this test fails on darwin due to case-insensitive file system
28 substituteInPlace pyfakefs/tests/fake_os_test.py \
29 --replace "test_rename_dir_to_existing_dir" "notest_rename_dir_to_existing_dir"
30 '');
31
32 nativeCheckInputs = [ pytestCheckHook ];
33 # https://github.com/jmcgeheeiv/pyfakefs/issues/581 (OSError: [Errno 9] Bad file descriptor)
34 disabledTests = [ "test_open_existing_pipe" ];
35
36 disabledTestPaths = [
37 # try to import opentimelineio but nixpkgs doesn't have it as of 2023-09-16
38 "pyfakefs/pytest_tests/segfault_test.py"
39 ];
40
41 pythonImportsCheck = [ "pyfakefs" ];
42
43 meta = with lib; {
44 description = "Fake file system that mocks the Python file system modules";
45 homepage = "http://pyfakefs.org/";
46 changelog = "https://github.com/jmcgeheeiv/pyfakefs/blob/master/CHANGES.md";
47 license = licenses.asl20;
48 maintainers = with maintainers; [ gebner ];
49 };
50}