hunk.code_window:         raise EnvCommandError(CalledProcessError(1, "python", output=""))
   def test_directory_dependency():
       dependency = DirectoryDependency("simple_project", fixtures_dir / "simple_project")
       assert dependency.pretty_name == "simple_project"
       assert dependency.develop
       assert dependency.path == fixtures_dir / "simple_project"
       assert dependency.base_pep_508_name == "simple_project @ {}".format(
           fixtures_dir / "simple_project"
       )
   def test_directory_dependency_must_exist():
       with pytest.raises(ValueError):
           DirectoryDependency("demo", DIST_PATH / "invalid")
hunk.labels: keep keep keep replace replace replace replace replace replace replace replace replace keep keep keep keep keep
hunk.after_edit: DIST_PATH = Path(__file__).parent.parent / "fixtures" / "git" / "github.com" / "demo"
  
hunk.file_path: tests/packages/test_directory_dependency.py
hunk.type: replace
file: import hashlib
  import io
  
  from pkginfo.distribution import HEADER_ATTRS
  from pkginfo.distribution import HEADER_ATTRS_2_0
  
  from poetry.utils._compat import Path
  
  from .dependency import Dependency
  
  
  # Patching pkginfo to support Metadata version 2.1 (PEP 566)
  HEADER_ATTRS.update(
      {"2.1": HEADER_ATTRS_2_0 + (("Provides-Extra", "provides_extra", True),)}
  )
  
  
  class FileDependency(Dependency):
      def __init__(
          self,
          name,
          path,  # type: Path
          category="main",  # type: str
          optional=False,  # type: bool
          base=None,  # type: Path
      ):
          self._path = path
          self._base = base
          self._full_path = path
  
          if self._base and not self._path.is_absolute():
              self._full_path = self._base / self._path
  
          if not self._full_path.exists():
              raise ValueError("File {} does not exist".format(self._path))
  
          if self._full_path.is_dir():
              raise ValueError("{} is a directory, expected a file".format(self._path))
  
          super(FileDependency, self).__init__(
              name, "*", category=category, optional=optional, allows_prereleases=True
          )
  
      @property
      def path(self):
          return self._path
  
      @property
      def full_path(self):
          return self._full_path.resolve()
  
      @property
      def base_pep_508_name(self):  # type: () -> str
          requirement = self.pretty_name
  
          if self.extras:
              requirement += "[{}]".format(",".join(self.extras))
  
          requirement += " @ {}".format(self._path)
  
          return requirement
  
      def is_file(self):
          return True
  
      def hash(self):
          h = hashlib.sha256()
          with self._full_path.open("rb") as fp:
              for content in iter(lambda: fp.read(io.DEFAULT_BUFFER_SIZE), b""):
                  h.update(content)
  
          return h.hexdigest()
  