mirror of
				https://github.com/enpaul/tox-poetry-installer.git
				synced 2025-11-03 07:39:20 +00:00 
			
		
		
		
	Fix linting errors and add docs to test functions
This commit is contained in:
		@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					# pylint: disable=missing-module-docstring, missing-function-docstring, unused-argument, too-few-public-methods
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
from pathlib import Path
 | 
					from pathlib import Path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -17,18 +18,23 @@ FAKE_VENV_PATH = Path("nowhere")
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MockVirtualEnv:
 | 
					class MockVirtualEnv:
 | 
				
			||||||
    class MockTestenvConfig:
 | 
					    """Mock class for the :class:`poetry.utils.env.VirtualEnv` and :class:`tox.venv.VirtualEnv`"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    class MockTestenvConfig:  # pylint: disable=missing-class-docstring
 | 
				
			||||||
        envdir = FAKE_VENV_PATH
 | 
					        envdir = FAKE_VENV_PATH
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, *args, **kwargs):
 | 
					    def __init__(self, *args, **kwargs):
 | 
				
			||||||
        self.envconfig = self.MockTestenvConfig()
 | 
					        self.envconfig = self.MockTestenvConfig()
 | 
				
			||||||
        self.installed = []
 | 
					        self.installed = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def is_valid_for_marker(self, *args, **kwargs):
 | 
					    @staticmethod
 | 
				
			||||||
 | 
					    def is_valid_for_marker(*args, **kwargs):
 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MockPipInstaller:
 | 
					class MockPipInstaller:
 | 
				
			||||||
 | 
					    """Mock class for the :class:`poetry.installation.pip_installer.PipInstaller`"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, env: MockVirtualEnv, **kwargs):
 | 
					    def __init__(self, env: MockVirtualEnv, **kwargs):
 | 
				
			||||||
        self.env = env
 | 
					        self.env = env
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
# pylint: disable=missing-module-docstring
 | 
					# pylint: disable=missing-module-docstring, redefined-outer-name, unused-argument, wrong-import-order, unused-import
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import tox.venv
 | 
					import tox.venv
 | 
				
			||||||
@@ -22,7 +22,7 @@ def test_deduplication(mock_venv, mock_poetry_factory):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    installer.install(poetry, venv, to_install)
 | 
					    installer.install(poetry, venv, to_install)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assert len(set(to_install)) == len(venv.installed)
 | 
					    assert len(set(to_install)) == len(venv.installed)  # pylint: disable=no-member
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_parallelization(mock_venv, mock_poetry_factory):
 | 
					def test_parallelization(mock_venv, mock_poetry_factory):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					# pylint: disable=missing-module-docstring, redefined-outer-name, unused-argument, wrong-import-order, unused-import
 | 
				
			||||||
import poetry.factory
 | 
					import poetry.factory
 | 
				
			||||||
import poetry.utils.env
 | 
					import poetry.utils.env
 | 
				
			||||||
import pytest
 | 
					import pytest
 | 
				
			||||||
@@ -12,6 +13,10 @@ from tox_poetry_installer import utilities
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_exclude_unsafe():
 | 
					def test_exclude_unsafe():
 | 
				
			||||||
 | 
					    """Test that the unsafe packages are properly excluded
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Also ensure that the internal constant matches the value from Poetry
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
    assert Provider.UNSAFE_PACKAGES == constants.UNSAFE_PACKAGES
 | 
					    assert Provider.UNSAFE_PACKAGES == constants.UNSAFE_PACKAGES
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for dep in constants.UNSAFE_PACKAGES:
 | 
					    for dep in constants.UNSAFE_PACKAGES:
 | 
				
			||||||
@@ -19,6 +24,7 @@ def test_exclude_unsafe():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_allow_missing():
 | 
					def test_allow_missing():
 | 
				
			||||||
 | 
					    """Test that the ``allow_missing`` parameter works as expected"""
 | 
				
			||||||
    with pytest.raises(exceptions.LockedDepNotFoundError):
 | 
					    with pytest.raises(exceptions.LockedDepNotFoundError):
 | 
				
			||||||
        utilities.identify_transients("luke-skywalker", dict(), None)
 | 
					        utilities.identify_transients("luke-skywalker", dict(), None)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -31,6 +37,7 @@ def test_allow_missing():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_exclude_pep508():
 | 
					def test_exclude_pep508():
 | 
				
			||||||
 | 
					    """Test that dependencies specified in PEP508 format are properly excluded"""
 | 
				
			||||||
    for version in [
 | 
					    for version in [
 | 
				
			||||||
        "foo==1.0",
 | 
					        "foo==1.0",
 | 
				
			||||||
        "foo==1",
 | 
					        "foo==1",
 | 
				
			||||||
@@ -48,11 +55,16 @@ def test_exclude_pep508():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_functional(mock_poetry_factory, mock_venv):
 | 
					def test_functional(mock_poetry_factory, mock_venv):
 | 
				
			||||||
 | 
					    """Integration tests for the :func:`identify_transients` function
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Trivially test that it resolves dependencies properly and that the parent package
 | 
				
			||||||
 | 
					    is always the last in the returned list.
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
    pypoetry = poetry.factory.Factory().create_poetry(None)
 | 
					    pypoetry = poetry.factory.Factory().create_poetry(None)
 | 
				
			||||||
    packages: datatypes.PackageMap = {
 | 
					    packages: datatypes.PackageMap = {
 | 
				
			||||||
        item.name: item for item in pypoetry.locker.locked_repository(False).packages
 | 
					        item.name: item for item in pypoetry.locker.locked_repository(False).packages
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    venv = poetry.utils.env.VirtualEnv()
 | 
					    venv = poetry.utils.env.VirtualEnv()  # pylint: disable=no-value-for-parameter
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    requests_requires = [
 | 
					    requests_requires = [
 | 
				
			||||||
        packages["certifi"],
 | 
					        packages["certifi"],
 | 
				
			||||||
@@ -70,3 +82,4 @@ def test_functional(mock_poetry_factory, mock_venv):
 | 
				
			|||||||
    for package in [packages["requests"], packages["tox"], packages["flask"]]:
 | 
					    for package in [packages["requests"], packages["tox"], packages["flask"]]:
 | 
				
			||||||
        transients = utilities.identify_transients(package, packages, venv)
 | 
					        transients = utilities.identify_transients(package, packages, venv)
 | 
				
			||||||
        assert transients[-1] == package
 | 
					        assert transients[-1] == package
 | 
				
			||||||
 | 
					        assert len(transients) == len(set(transients))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user