aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVitiko <[email protected]>2023-05-17 22:50:15 -0400
committerVitiko <[email protected]>2023-05-17 22:54:07 -0400
commitea7b9487ab145a39d83188e92bf8cc9e96064b80 (patch)
tree982515a41f356b9b05269f577c777d428de3d91f
parentbdf4ee85af7bd9f194da82420f66649e964650a1 (diff)
downloadbazarr-ea7b9487ab145a39d83188e92bf8cc9e96064b80.tar.gz
bazarr-ea7b9487ab145a39d83188e92bf8cc9e96064b80.zip
no log: Add tests header warning
-rw-r--r--dev-requirements.txt1
-rw-r--r--tests/conftest.py26
2 files changed, 27 insertions, 0 deletions
diff --git a/dev-requirements.txt b/dev-requirements.txt
index 550ab0d0e..5241aefd7 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -7,3 +7,4 @@ pytest-cov
pytest-vcr
pytest-mock
requests-mock
+setuptools
diff --git a/tests/conftest.py b/tests/conftest.py
index 311264122..46d8fc4a0 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,6 +1,32 @@
# -*- coding: utf-8 -*-
import os
+import pkgutil
import sys
+import pkg_resources
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../libs/"))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../bazarr/"))
+
+
+def pytest_report_header(config):
+ conflicting_packages = _get_conflicting("libs")
+ if conflicting_packages:
+ return f"Conflicting packages detected:\n{conflicting_packages}"
+
+
+def _get_conflicting(path):
+ libs_packages = []
+ for _, package_name, _ in pkgutil.iter_modules([path]):
+ libs_packages.append(package_name)
+
+ installed_packages = pkg_resources.working_set
+ package_names = [package.key for package in installed_packages]
+ unique_package_names = set(package_names)
+
+ conflicting = []
+ for installed in unique_package_names:
+ if installed in libs_packages:
+ conflicting.append(installed)
+
+ return conflicting