2019-11-30 18:11:00 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import os
|
2023-05-18 10:50:15 +08:00
|
|
|
import pkgutil
|
2021-12-01 05:49:28 +08:00
|
|
|
import sys
|
2019-11-30 18:11:00 +08:00
|
|
|
|
2023-05-18 10:50:15 +08:00
|
|
|
import pkg_resources
|
|
|
|
|
2021-12-01 05:49:28 +08:00
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../libs/"))
|
2022-06-22 03:50:31 +08:00
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../bazarr/"))
|
2023-05-18 10:50:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
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
|