Repository: amogorkon/justuse (language: python)

Issue:
Feature/mass testing



Discussion / hints:

Fix patch:
diff --git a/setup.py b/setup.py
index 71709c28..f8e7eaf2 100644
--- a/setup.py
+++ b/setup.py
@@ -36,7 +36,6 @@
 
 meta = {
     "name": "justuse",
-    "description": "A beautiful, simple and explicit way to import modules in Python with advanced features.",
     "license": "MIT",
     "url": "https://github.com/amogorkon/justuse",
     "version": version,
@@ -60,21 +59,18 @@
         "Operating System :: OS Independent",
         "Programming Language :: Python :: 3 :: Only",
     ],
-    "extras_require": {
-        "test": ["pytest", "pytest-cov", "pytest-env"]
-    },
+    "extras_require": {"test": ["pytest", "pytest-cov", "pytest-env"]},
     "fullname": "justuse",
     "dist_files": ["pytest.ini", "tests/pytest.ini"],
     "description": "a pure-python alternative to import",
     "maintainer_email": "justuse-pypi@anselm.kiefner.de",
     "maintainer": "Anselm Kiefner",
     "platforms": ["any"],
-    "download_url": (
-        "https://github.com/amogorkon/justuse/"
-        "archive/refs/heads/main.zip"
-    )
+    "download_url": "https://github.com/amogorkon/justuse/"
+    "archive/refs/heads/main.zip",
 }
 
+
 requires = (
     "requests(>= 2.24.0)",
     "packaging(>= 21.0)",
diff --git a/src/use/use.py b/src/use/use.py
index 12231258..36ee9a7d 100755
--- a/src/use/use.py
+++ b/src/use/use.py
@@ -1038,37 +1038,37 @@ def _load_venv_entry(name, installation_path, module_path) -> ModuleType:
     package_name, rest = _parse_name(name)
     orig_exc = None
     old_sys_path = list(sys.path)
-    if "" != sys.path[0]:
-      sys.path.insert(0, "")
+    if sys.path[0] != "":
+        sys.path.insert(0, "")
     with open(module_path, "rb") as code_file:
-      try:
-        for variant in (
-          installation_path,
-          Path(str(str(installation_path).replace("lib64/","lib/"))),
-          Path(str(str(installation_path).replace("lib/","lib64/"))),
-          None
-        ):
-          if not variant: raise RuntimeError()
-          if not variant.exists(): continue
-          try:
-            os.chdir(cwd)
-            os.chdir(variant)
-            return _build_mod(
-                name=rest,
-                code=code_file.read(),
-                module_path=_ensure_path(module_path),
-                initial_globals={},
-                aspectize={},
-            )
-          except (ImportError, ModuleNotFoundError) as ierr0:
-            orig_exc = orig_exc or ierr0
-            continue
-      except RuntimeError as ierr:
-            try:
-                return importlib.import_module(rest)
-            except BaseException as ierr2:
-                raise ierr from orig_exc
-      finally:
+        try:
+            for variant in     (
+              installation_path,
+              Path(str(str(installation_path).replace("lib64/","lib/"))),
+              Path(str(str(installation_path).replace("lib/","lib64/"))),
+              None
+            ):
+                if not variant: raise RuntimeError()
+                if not variant.exists(): continue
+                try:
+                    os.chdir(cwd)
+                    os.chdir(variant)
+                    return _build_mod(
+                        name=rest,
+                        code=code_file.read(),
+                        module_path=_ensure_path(module_path),
+                        initial_globals={},
+                        aspectize={},
+                    )
+                except ImportError as ierr0:
+                    orig_exc = orig_exc or ierr0
+                    continue
+        except RuntimeError as ierr:
+              try:
+                  return importlib.import_module(rest)
+              except BaseException as ierr2:
+                  raise ierr from orig_exc
+        finally:
             os.chdir(cwd)
             sys.path.clear()
             for p in old_sys_path:


Test patch:
diff --git a/tests/mass/pypi_model.py b/tests/mass/pypi_model.py
index d8be0389..107f68d5 100644
--- a/tests/mass/pypi_model.py
+++ b/tests/mass/pypi_model.py
@@ -190,15 +190,20 @@ def filter_by_version(self, version: str) -> "PyPI_Project":
         )
 
     def filter_by_platform(self, tags: FrozenSet[PlatformTag], sys_version: Version) -> "PyPI_Project":
-        filtered = {}
-        for ver, releases in self.releases.items():
-            filtered[ver] = list(
-                (
-                    rel.dict()
-                    for rel in releases
-                    if _is_compatible(rel, sys_version=sys_version, platform_tags=tags, include_sdist=True)
+        filtered = {
+            ver: [
+                rel.dict()
+                for rel in releases
+                if _is_compatible(
+                    rel,
+                    sys_version=sys_version,
+                    platform_tags=tags,
+                    include_sdist=True,
                 )
-            )
+            ]
+            for ver, releases in self.releases.items()
+        }
+
         return PyPI_Project(**{**self.dict(), **{"releases": filtered}})
 
     def filter_by_version_and_current_platform(self, version: str) -> "PyPI_Project":
@@ -247,8 +252,7 @@ def _is_version_satisfied(specifier: str, sys_version) -> bool:
     @see https://packaging.pypa.io/en/latest/specifiers.html
     """
     specifiers = SpecifierSet(specifier or "")
-    is_match = sys_version in specifiers
-    return is_match
+    return sys_version in specifiers
 
 
 def _is_compatible(info: PyPI_Release, sys_version, platform_tags, include_sdist=None) -> bool:
diff --git a/tests/mass/use.py b/tests/mass/use.py
index 3877b8ec..1e88af2b 100755
--- a/tests/mass/use.py
+++ b/tests/mass/use.py
@@ -1034,37 +1034,37 @@ def _load_venv_entry(name, installation_path, module_path) -> ModuleType:
     package_name, rest = _parse_name(name)
     orig_exc = None
     old_sys_path = list(sys.path)
-    if "" != sys.path[0]:
-      sys.path.insert(0, "")
+    if sys.path[0] != "":
+        sys.path.insert(0, "")
     with open(module_path, "rb") as code_file:
-      try:
-        for variant in (
-          installation_path,
-          Path(str(str(installation_path).replace("lib64/","lib/"))),
-          Path(str(str(installation_path).replace("lib/","lib64/"))),
-          None
-        ):
-          if not variant: raise RuntimeError()
-          if not variant.exists(): continue
-          try:
-            os.chdir(cwd)
-            os.chdir(variant)
-            return _build_mod(
-                name=rest,
-                code=code_file.read(),
-                module_path=_ensure_path(module_path),
-                initial_globals={},
-                aspectize={},
-            )
-          except (ImportError, ModuleNotFoundError) as ierr0:
-            orig_exc = orig_exc or ierr0
-            continue
-      except RuntimeError as ierr:
-            try:
-                return importlib.import_module(rest)
-            except BaseException as ierr2:
-                raise ierr from orig_exc
-      finally:
+        try:
+            for variant in     (
+              installation_path,
+              Path(str(str(installation_path).replace("lib64/","lib/"))),
+              Path(str(str(installation_path).replace("lib/","lib64/"))),
+              None
+            ):
+                if not variant: raise RuntimeError()
+                if not variant.exists(): continue
+                try:
+                    os.chdir(cwd)
+                    os.chdir(variant)
+                    return _build_mod(
+                        name=rest,
+                        code=code_file.read(),
+                        module_path=_ensure_path(module_path),
+                        initial_globals={},
+                        aspectize={},
+                    )
+                except ImportError as ierr0:
+                    orig_exc = orig_exc or ierr0
+                    continue
+        except RuntimeError as ierr:
+              try:
+                  return importlib.import_module(rest)
+              except BaseException as ierr2:
+                  raise ierr from orig_exc
+        finally:
             os.chdir(cwd)
             sys.path.clear()
             for p in old_sys_path:
@@ -2036,8 +2036,6 @@ def _use_str(
             aspectize=aspectize,
             modes=modes,
         )
-        package_name = name.split("/")[0]
-        rest = module_name = name.split("/")[-1]
     def _use_package(
         self,
         *,