Skip to content

Commit

Permalink
fixed an issue with requirements.txt not being found if not in root d…
Browse files Browse the repository at this point in the history
…irectory (#94)
  • Loading branch information
Florian Maas authored Sep 12, 2022
1 parent 2babe8a commit f6d8a4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deptry/dependency_specification_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ def _check_if_project_uses_pyproject_toml_for_dependencies():
return False

def _check_if_project_uses_requirements_txt_for_dependencies(self):
if self.requirements_txt in os.listdir():
if os.path.isfile(self.requirements_txt):
return True
return False
11 changes: 11 additions & 0 deletions tests/test_dependency_specification_detector.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from distutils.command.config import config

from deptry.config import Config
Expand Down Expand Up @@ -47,3 +48,13 @@ def test_requirements_txt_with_argument(tmp_path):

spec = DependencySpecificationDetector(requirements_txt="req.txt").detect()
assert spec == "requirements_txt"


def test_requirements_txt_with_argument(tmp_path):
with run_within_dir(tmp_path):
os.mkdir("req")
with open("req/req.txt", "w") as f:
f.write('foo >= "1.0"')

spec = DependencySpecificationDetector(requirements_txt="req/req.txt").detect()
assert spec == "requirements_txt"

0 comments on commit f6d8a4b

Please sign in to comment.