Skip to content

GitPython causes AttributeError: 'FakePipeWrapper' object has no attribute 'closed' #649

@hofbi

Description

@hofbi

Describe the bug

If I am writing functions that interact with a git repository, I usually use GitPython.
To test these function, pyfakefs would be great.
So far, it seems that it is not supported.
Additionally, it is not listed in https://jmcgeheeiv.github.io/pyfakefs/master/usage.html#modules-not-working-with-pyfakefs

MWE and stacktrace below

How To Reproduce

Please provide a unit test or a minimal code snippet that reproduces the
problem.

from pyfakefs.fake_filesystem_unittest import TestCase
import git


class GitTest(TestCase):
    def setUp(self) -> None:
        self.setUpPyfakefs()

    def test_git(self):
        self.fs.create_dir("test")
        git.Repo.init("test")
Error
Traceback (most recent call last):
  File "mwe.py", line 16, in test_git
    git.Repo.init("test")
  File "venv/lib/python3.8/site-packages/git/repo/base.py", line 1046, in init
    git.init(**kwargs)
  File "venv/lib/python3.8/site-packages/git/cmd.py", line 638, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
  File "venv/lib/python3.8/site-packages/git/cmd.py", line 1183, in _call_process
    return self.execute(call, **exec_kwargs)
  File "venv/lib/python3.8/site-packages/git/cmd.py", line 937, in execute
    stdout_value, stderr_value = proc.communicate()
  File "/usr/lib/python3.8/subprocess.py", line 1028, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/usr/lib/python3.8/subprocess.py", line 1853, in _communicate
    if self.stdout and not self.stdout.closed:
AttributeError: 'FakePipeWrapper' object has no attribute 'closed'

Your environment

Linux-5.4.0-90-generic-x86_64-with-glibc2.29
Python 3.8.10
[GCC 9.3.0]
pyfakefs 4.5.3
git 3.1.24

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions