mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-03 01:50:11 +00:00
Add test for duplicated dependencies
This commit is contained in:
parent
36efe7e219
commit
c3761598ce
6
tests/_data_duplicated_deps/db.py
Normal file
6
tests/_data_duplicated_deps/db.py
Normal file
@ -0,0 +1,6 @@
|
||||
import pymongo
|
||||
from bson.objectid import ObjectId
|
||||
|
||||
# 'bson' package is mapped to 'pymongo'.
|
||||
# But running pipreqs should not result in two duplicated
|
||||
# lines 'pymongo==x.x.x'.
|
@ -26,6 +26,7 @@ class TestPipreqs(unittest.TestCase):
|
||||
self.project = os.path.join(os.path.dirname(__file__), "_data")
|
||||
self.project_invalid = os.path.join(os.path.dirname(__file__), "_invalid_data")
|
||||
self.project_with_ignore_directory = os.path.join(os.path.dirname(__file__), "_data_ignore")
|
||||
self.project_with_duplicated_deps = os.path.join(os.path.dirname(__file__), "_data_duplicated_deps")
|
||||
self.requirements_path = os.path.join(self.project, "requirements.txt")
|
||||
self.alt_requirement_path = os.path.join(
|
||||
self.project, "requirements2.txt")
|
||||
@ -43,6 +44,12 @@ class TestPipreqs(unittest.TestCase):
|
||||
self.assertFalse("django" in imports)
|
||||
self.assertFalse("models" in imports)
|
||||
|
||||
def test_deduplicate_dependencies(self):
|
||||
imports = pipreqs.get_all_imports(self.project_with_duplicated_deps)
|
||||
pkgs = pipreqs.get_pkg_names(imports)
|
||||
self.assertEqual(len(pkgs), 1)
|
||||
self.assertIn("pymongo", pkgs)
|
||||
|
||||
def test_invalid_python(self):
|
||||
"""
|
||||
Test that invalid python files cannot be imported.
|
||||
|
Loading…
x
Reference in New Issue
Block a user