Repository: AustinScola/pytest-motor (language: python)

Issue:
Other OS support
Hello @AustinScola!

I know that your project currently supports only Ubuntu (as issue #13 says) so this issue should be marked as enhancement. However, if you're planning on adding Windows support (which I'm personally really looking forward), here is my small research.

Seems like PR #21 adds an ability to run your add-on on macOS. I tweaked frepond's fork to support Windows. Predictably, it doesn't work because of Unix sockets. So one way is to implement sockets part differently.

Another suggestion I have is to add an ability to run over an existing MongoDB installation or MongoDB docker container. It might be configured with setup.cfg near to pytest itself.

Anyway, I'm leaving this decision up to you. Let me know if I can help with code.
Allow mongodb version selection
It would be nice to let the user of the plugin choose the version of the mongodb binary to use.


Discussion / hints:
Hey @aleksul, you are correct that `pytest-motor` only supports Ubuntu at the moment and that MacOS support is in the process of being added. I didn't have any plans to add Windows support in the near future, but I would be more than happy to work with you or others on adding it if you desire. (I don't have a Windows machine to test on though.)

My first thought for support would be to use a random port instead. I know that `aiohttp` has a method [`pytest_aiohttp.aiohttp_unused_port`](https://docs.aiohttp.org/en/latest/testing.html#pytest_aiohttp.aiohttp_unused_port) for finding a random port. We could look at how that is implemented for reference.

I like the sound of using an existing installation or MongoDB docker container as well too. Those both sound like longer term efforts though.


Ok, so it sounds like firstly we need to resolve #17. I will create PR asap.


Fix patch:
diff --git a/mypy.ini b/mypy.ini
index db528a6..6210fd9 100644
--- a/mypy.ini
+++ b/mypy.ini
@@ -2,7 +2,7 @@
 python_version = 3.6
 warn_return_any = True
 warn_unused_configs = True
-exclude=/venvs/
+exclude=venvs/
 
 disallow_untyped_defs=True
 
@@ -20,3 +20,9 @@ ignore_missing_imports = True
 
 [mypy-pymongo.*]
 ignore_missing_imports = True
+
+[mypy-distro.*]
+ignore_missing_imports = True
+
+[mypy-pytest_lazyfixture.*]
+ignore_missing_imports = True
diff --git a/requirements/frozen/frozen_coverage_requirements.txt b/requirements/frozen/frozen_coverage_requirements.txt
index c988e71..cb4c211 100644
--- a/requirements/frozen/frozen_coverage_requirements.txt
+++ b/requirements/frozen/frozen_coverage_requirements.txt
@@ -3,6 +3,7 @@ async-timeout==3.0.1
 attrs==21.2.0
 chardet==4.0.0
 coverage==5.5
+distro==1.5.0
 idna==3.2
 idna-ssl==1.1.0
 importlib-metadata==4.6.1
@@ -17,6 +18,7 @@ pyparsing==2.4.7
 pytest==6.2.4
 pytest-asyncio==0.15.1
 pytest-cov==2.12.1
+pytest-lazy-fixture==0.6.3
 toml==0.10.2
 typing-extensions==3.10.0.0
 yarl==1.6.3
diff --git a/requirements/frozen/frozen_lint_requirements.txt b/requirements/frozen/frozen_lint_requirements.txt
index e3bbfef..e6baa44 100644
--- a/requirements/frozen/frozen_lint_requirements.txt
+++ b/requirements/frozen/frozen_lint_requirements.txt
@@ -3,6 +3,7 @@ astroid==2.5.6
 async-timeout==3.0.1
 attrs==21.2.0
 chardet==4.0.0
+distro==1.5.0
 idna==3.2
 idna-ssl==1.1.0
 importlib-metadata==4.6.1
@@ -20,6 +21,7 @@ pymongo==3.12.0
 pyparsing==2.4.7
 pytest==6.2.4
 pytest-asyncio==0.15.1
+pytest-lazy-fixture==0.6.3
 toml==0.10.2
 typed-ast==1.4.3
 typing-extensions==3.10.0.0
diff --git a/requirements/frozen/frozen_type_check_requirements.txt b/requirements/frozen/frozen_type_check_requirements.txt
index 000d402..cd7d1fc 100644
--- a/requirements/frozen/frozen_type_check_requirements.txt
+++ b/requirements/frozen/frozen_type_check_requirements.txt
@@ -2,6 +2,7 @@ aiohttp==3.7.4.post0
 async-timeout==3.0.1
 attrs==21.2.0
 chardet==4.0.0
+distro==1.5.0
 idna==3.2
 idna-ssl==1.1.0
 importlib-metadata==4.6.1
@@ -17,6 +18,7 @@ pymongo==3.12.0
 pyparsing==2.4.7
 pytest==6.2.4
 pytest-asyncio==0.15.1
+pytest-lazy-fixture==0.6.3
 toml==0.10.2
 typed-ast==1.4.3
 typing-extensions==3.10.0.0
diff --git a/requirements/requirements.txt b/requirements/requirements.txt
index 9ad97b3..c9113de 100644
--- a/requirements/requirements.txt
+++ b/requirements/requirements.txt
@@ -2,3 +2,4 @@ motor==2.4.0
 pytest==6.2.4
 pytest-asyncio==0.15.1 # Needed for async pytest fixtures
 aiohttp==3.7.4.post0
+distro==1.5.0
diff --git a/setup.py b/setup.py
index da860a6..e8f77eb 100644
--- a/setup.py
+++ b/setup.py
@@ -36,5 +36,5 @@
         'Typing :: Typed',
     ],
     python_requires='>=3.6',
-    install_requires=['pytest', 'motor', 'aiohttp'],
+    install_requires=['pytest', 'motor', 'aiohttp', 'distro'],
 )


Test patch:
diff --git a/pytest_motor/mongod_binary.py b/pytest_motor/mongod_binary.py
new file mode 100644
index 0000000..f571d3e
--- /dev/null
+++ b/pytest_motor/mongod_binary.py
@@ -0,0 +1,151 @@
+"""This module helps with mongodb binary."""
+import platform
+import shutil
+import tarfile
+import tempfile
+import warnings
+from pathlib import Path
+from typing import IO
+from zipfile import ZipFile
+
+import aiohttp
+import distro
+
+
+class MongodBinary:
+    """This class helps with mongodb binary."""
+    MONGO_VERSION: str = '4.4.6'  # FUTURE: mongod binary version selector via config
+
+    def __init__(self, destination: Path):
+        destination.mkdir(parents=True, exist_ok=True)
+        self.path: Path = destination / self.binary_name
+        self.url: str = f'https://fastdl.mongodb.org/' \
+                        f'{self.current_os}/' \
+                        f'mongodb-{self.current_platform}-' \
+                        f'{self.MONGO_VERSION}.' \
+                        f'{"zip" if platform.system() == "Windows" else "tgz"}'
+
+    @property
+    def exists(self) -> bool:
+        """Return true if mongodb binary already exists."""
+        return self.path.exists()  # pragma: no cover
+
+    @property
+    def current_os(self) -> str:
+        """Return OS as it spells in mongodb binary url."""
+        translation = {'Linux': 'linux', 'Darwin': 'osx', 'Windows': 'windows'}
+        system: str = platform.system()
+        result = translation.get(system)
+        if result is None:
+            raise OSError("Your platform is unsupported.")
+        return result
+
+    @property
+    def binary_name(self) -> str:
+        """Return mongodb binary name with extension."""
+        return f'mongod{".exe" if platform.system() == "Windows" else ""}'  # pragma: no cover
+
+    @property
+    def current_platform(self) -> str:
+        """Return mongo platform as it spells in mongodb binary url."""
+        # FUTURE: ARM support
+        system = platform.system()
+        if system == 'Linux':
+            distro_name = distro.id()
+            if distro_name == 'ubuntu':
+                return 'linux-x86_64-' + MongodBinary.__select_ubuntu_version()
+            if distro_name == 'debian':
+                return 'linux-x86_64-' + MongodBinary.__select_debian_version()
+            # FUTURE: distros that may be added: Amazon Linux, CentOS, SUSE
+            raise OSError(f"Your distro ({distro_name}) is unsupported.")
+
+        if system == 'Darwin':
+            return 'macos-x86_64'
+
+        if system == 'Windows':
+            return 'windows-x86_64'
+
+        raise OSError("Your platform is unsupported.")  # pragma: no cover
+
+    async def download_and_unpack(self) -> Path:
+        """Return path to downloaded and unpacked mongod binary."""
+        async with aiohttp.ClientSession() as session:
+            async with session.get(self.url) as resp:
+                with tempfile.TemporaryFile(mode='w+b') as binary_file:
+                    # Read by chunks to avoid big RAM consumption
+                    while True:
+                        # read by 100 bytes
+                        chunk = await resp.content.read(100)
+                        if not chunk:
+                            break
+                        binary_file.write(chunk)
+                    binary_file.flush()
+                    binary_file.seek(0)
+                    self.__unpack(binary_file)
+                    return self.path
+
+    def __unpack(self, binary_file: IO[bytes]) -> None:
+        """Unpack mongod binary from zip or tar."""
+        if self.url.endswith('.tgz'):
+            with tarfile.open(fileobj=binary_file) as archive_tar:
+                file_in_archive = archive_tar.extractfile(
+                    f'mongodb-{self.current_platform}-{self.MONGO_VERSION}/bin/mongod')
+                if file_in_archive is None:  # pragma: no cover
+                    raise FileNotFoundError
+                file_outside = self.path.open(mode="wb")
+                with file_in_archive, file_outside:
+                    shutil.copyfileobj(file_in_archive, file_outside)
+                self.path.chmod(0o700)
+            assert self.path.exists(), "Unsuccessful mongod binary extraction"
+            return
+        if self.url.endswith('.zip') and self.current_platform == 'windows-x86_64':
+            with ZipFile(file=binary_file, mode='r') as archive_zip:
+                # pylint: disable=consider-using-with
+                file_in_archive = archive_zip.open(
+                    f'mongodb-win32-x86_64-windows-{self.MONGO_VERSION}/bin/mongod.exe')
+                if file_in_archive is None:  # pragma: no cover
+                    raise FileNotFoundError
+                file_outside = self.path.open(mode="wb")
+                with file_in_archive, file_outside:
+                    shutil.copyfileobj(file_in_archive, file_outside)
+                self.path.chmod(0o700)
+            assert self.path.exists(), "Unsuccessful mongod binary extraction"
+            return
+        raise Exception("Unsupported archive format.")  # pragma: no cover
+
+    @staticmethod
+    def __select_ubuntu_version() -> str:
+        if bool(distro.major_version()) and int(distro.major_version()) < 16:
+            raise OSError("Your Ubuntu version is too old. Upgrade at least to 16.")
+
+        if distro.version() == '16.04':
+            MongodBinary.warn_untested_os()
+            return 'ubuntu1604'
+        if distro.version() == '18.04':
+            return 'ubuntu1804'
+        if distro.version() == '20.04':
+            return 'ubuntu2004'
+
+        warnings.warn("Can't detect your Ubuntu version. Fallback to 18.04.")
+        return 'ubuntu1804'
+
+    @staticmethod
+    def __select_debian_version() -> str:
+        if bool(distro.major_version()) and int(distro.major_version()) < 9:
+            raise OSError(
+                "Your Debian version is too old. Upgrade at least to 9.")  # pragma: no cover
+
+        if distro.version() == '9.2':
+            MongodBinary.warn_untested_os()
+            return 'debian92'
+        if distro.version() == '10.0':
+            MongodBinary.warn_untested_os()
+            return 'debian10'
+
+        warnings.warn("Can't detect your Debian version. Fallback to 9.2.")
+        return 'debian92'
+
+    @staticmethod
+    def warn_untested_os() -> None:
+        """Throws a warning about your OS not beeing tested by contributors."""
+        warnings.warn("Your OS support was NOT properly tested.")
diff --git a/pytest_motor/plugin.py b/pytest_motor/plugin.py
index bcb79b2..8ff7a72 100644
--- a/pytest_motor/plugin.py
+++ b/pytest_motor/plugin.py
@@ -1,19 +1,17 @@
 """A pytest plugin which helps test applications using Motor."""
 import asyncio
-import platform
 import secrets
 import shutil
 import socket
-import tarfile
-import tempfile
 from pathlib import Path
-from typing import AsyncIterator, Iterator, List, Tuple
+from typing import AsyncIterator, Iterator, List
 
-import aiohttp
 import pytest
 from _pytest.config import Config as PytestConfig
 from motor.motor_asyncio import AsyncIOMotorClient
 
+from pytest_motor.mongod_binary import MongodBinary
+
 
 def _event_loop() -> Iterator[asyncio.AbstractEventLoop]:
     """Yield an event loop.
@@ -37,32 +35,14 @@ async def root_directory(pytestconfig: PytestConfig) -> Path:
 
 
 @pytest.fixture(scope='session')
-async def mongod_binary(root_directory: Path) -> Path:  # pylint: disable=redefined-outer-name
+async def mongod_binary(root_directory: Path) -> Path:
+    # pylint: disable=redefined-outer-name
     """Return a path to a mongod binary."""
-    destination: Path = root_directory.joinpath('.mongod')
-    os_ver, mongo_ver = _mongo_ver()
-    mongod_binary_relative_path = f'{mongo_ver}/bin/mongod'
-    mongod_binary_path = destination.joinpath(mongod_binary_relative_path)
-
-    if not mongod_binary_path.exists():
-        download_url = f'https://fastdl.mongodb.org/{os_ver}/{mongo_ver}.tgz'
-        async with aiohttp.ClientSession() as session:
-            async with session.get(download_url) as resp:
-                with tempfile.TemporaryFile(mode='w+b') as binary_file:
-                    # Read by chunks to avoid big RAM consumption
-                    while True:
-                        # read by 100 bytes
-                        chunk = await resp.content.read(100)
-                        if not chunk:
-                            break
-                        binary_file.write(chunk)
-                    binary_file.flush()
-                    binary_file.seek(0)
-                    # Extract tar
-                    with tarfile.open(fileobj=binary_file) as tar:
-                        tar.extract(member=mongod_binary_relative_path, path=destination)
-
-    return mongod_binary_path
+    destination: Path = root_directory / '.mongod'
+    binary = MongodBinary(destination=destination)
+    if not binary.exists:
+        await binary.download_and_unpack()
+    return binary.path
 
 
 @pytest.fixture(scope='function')
@@ -76,8 +56,8 @@ def new_port() -> int:
 
 
 @pytest.fixture(scope='function')
-# pylint: disable=redefined-outer-name
 async def databases_directory(root_directory: Path) -> AsyncIterator[Path]:
+    # pylint: disable=redefined-outer-name
     """Yield a directory for mongod to store data."""
     databases_directory = root_directory.joinpath('.mongo_databases')
     databases_directory.mkdir(exist_ok=True)
@@ -86,8 +66,8 @@ async def databases_directory(root_directory: Path) -> AsyncIterator[Path]:
 
 
 @pytest.fixture(scope='function')
-# pylint: disable=redefined-outer-name
 async def database_path(databases_directory: Path) -> AsyncIterator[Path]:
+    # pylint: disable=redefined-outer-name
     """Yield a database path for a mongod process to store data."""
     name: str = secrets.token_hex(12)
     database_path: Path = databases_directory.joinpath(name)
@@ -99,9 +79,9 @@ async def database_path(databases_directory: Path) -> AsyncIterator[Path]:
 
 
 @pytest.fixture(scope='function')
-# pylint: disable=redefined-outer-name
 async def mongod_socket(new_port: int, database_path: Path,
                         mongod_binary: Path) -> AsyncIterator[str]:
+    # pylint: disable=redefined-outer-name
     """Yield a mongod."""
     # yapf: disable
     arguments: List[str] = [
@@ -125,8 +105,8 @@ async def mongod_socket(new_port: int, database_path: Path,
 
 
 @pytest.fixture(scope='function')
-# pylint: disable=redefined-outer-name
 async def motor_client(mongod_socket: str) -> AsyncIterator[AsyncIOMotorClient]:
+    # pylint: disable=redefined-outer-name
     """Yield a Motor client."""
     connection_string = f'mongodb://{mongod_socket}'
 
@@ -136,15 +116,3 @@ async def motor_client(mongod_socket: str) -> AsyncIterator[AsyncIOMotorClient]:
     yield motor_client_
 
     motor_client_.close()
-
-
-def _mongo_ver() -> Tuple[str, str]:
-    """Return mongo version based on platform system."""
-    if platform.system() == 'Linux':
-        mongo_exec = "linux", 'mongodb-linux-x86_64-ubuntu1804-4.4.6'
-    elif platform.system() == 'Darwin':
-        mongo_exec = "osx", 'mongodb-macos-x86_64-4.4.6'
-    else:
-        raise Exception("Unsupported platform")
-
-    return mongo_exec
diff --git a/requirements/frozen/frozen_test_requirements.txt b/requirements/frozen/frozen_test_requirements.txt
index 4d8a915..6a34e8a 100644
--- a/requirements/frozen/frozen_test_requirements.txt
+++ b/requirements/frozen/frozen_test_requirements.txt
@@ -2,6 +2,7 @@ aiohttp==3.7.4.post0
 async-timeout==3.0.1
 attrs==21.2.0
 chardet==4.0.0
+distro==1.5.0
 idna==3.2
 idna-ssl==1.1.0
 importlib-metadata==4.6.1
@@ -15,6 +16,7 @@ pymongo==3.12.0
 pyparsing==2.4.7
 pytest==6.2.4
 pytest-asyncio==0.15.1
+pytest-lazy-fixture==0.6.3
 toml==0.10.2
 typing-extensions==3.10.0.0
 yarl==1.6.3
diff --git a/requirements/test_requirements.txt b/requirements/test_requirements.txt
index fec6a6f..6fd9354 100644
--- a/requirements/test_requirements.txt
+++ b/requirements/test_requirements.txt
@@ -1,2 +1,3 @@
 -r requirements.txt
 pytest-asyncio==0.15.1
+pytest-lazy-fixture==0.6.3
diff --git a/tests/test_mongod_binary.py b/tests/test_mongod_binary.py
new file mode 100644
index 0000000..2c57b9a
--- /dev/null
+++ b/tests/test_mongod_binary.py
@@ -0,0 +1,105 @@
+"""Test pytest_motor.mongod_binary."""
+import tarfile
+import tempfile
+from io import BytesIO
+from pathlib import Path
+from typing import IO, Iterator
+from zipfile import ZIP_DEFLATED, ZipFile
+
+from pytest import MonkeyPatch, fixture, mark, param
+from pytest_lazyfixture import lazy_fixture
+
+from pytest_motor.mongod_binary import MongodBinary
+
+
+@fixture(scope='session')
+def mongodb_archive_windows() -> Iterator[IO]:
+    """Yield a .zip archive with mongod located as in original Windows archive."""
+    with tempfile.TemporaryDirectory() as tmpdir:
+        myfile = Path(tmpdir) / "mongod.zip"
+        with ZipFile(file=myfile, mode='w') as archive_zip:
+            archive_zip.writestr("mongodb-win32-x86_64-windows-4.4.6/bin/mongod.exe", 'hello',
+                                 ZIP_DEFLATED)
+        yield myfile.open('rb')
+
+
+@fixture(scope='session')
+def mongodb_archive_macos() -> Iterator[IO]:
+    """Yield a .tgz archive with mongod located as in original macOS archive."""
+    with tempfile.TemporaryDirectory() as tmpdir:
+        myfile = Path(tmpdir) / "mongod.tgz"
+        with tarfile.open(myfile, mode="w:gz") as archive_tar:
+            info = tarfile.TarInfo(name="mongodb-macos-x86_64-4.4.6/bin/mongod")
+            archive_tar.addfile(info, BytesIO(b'hello'))
+        yield myfile.open('rb')
+
+
+@mark.parametrize('platform_name, distro_name, distro_version, result', [
+    param('Java', '', '', 'Java', marks=mark.xfail(raises=OSError, strict=True)),
+    param('Linux',
+          'ubuntu',
+          '14.04',
+          'linux-x86_64-ubuntu1404',
+          marks=mark.xfail(raises=OSError, strict=True)),
+    ('Linux', 'ubuntu', '16.04', 'linux-x86_64-ubuntu1604'),
+    ('Linux', 'ubuntu', '18.04', 'linux-x86_64-ubuntu1804'),
+    ('Linux', 'ubuntu', '20.04', 'linux-x86_64-ubuntu2004'),
+    ('Linux', 'ubuntu', '19.04', 'linux-x86_64-ubuntu1804'),
+    param('Linux',
+          'Debian',
+          '8.0',
+          'linux-x86_64-debian80',
+          marks=mark.xfail(raises=OSError, strict=True)),
+    ('Linux', 'debian', '9.2', 'linux-x86_64-debian92'),
+    ('Linux', 'debian', '10.0', 'linux-x86_64-debian10'),
+    ('Linux', 'debian', '9.0', 'linux-x86_64-debian92'),
+    param('Linux',
+          'opensuse',
+          '8.0',
+          'linux-x86_64-opensuse80',
+          marks=mark.xfail(raises=OSError, strict=True)),
+    ('Darwin', '', '', 'macos-x86_64'),
+    ('Windows', '', '', 'windows-x86_64'),
+])
+@mark.filterwarnings("ignore::Warning")
+def test_mongo_platform(monkeypatch: MonkeyPatch, platform_name: str, distro_name: str,
+                        distro_version: str, result: str) -> None:
+    """Test mongodb platform selection."""
+
+    monkeypatch.setattr("platform.system", lambda: platform_name)
+    monkeypatch.setattr("distro.id", lambda: distro_name)
+    monkeypatch.setattr("distro.version", lambda: distro_version)
+    monkeypatch.setattr("distro.major_version", lambda: distro_version.split('.')[0])
+    assert MongodBinary(Path(tempfile.gettempdir())).current_platform == result
+
+
+@mark.parametrize(
+    'platform_name, distro_name, distro_version, true_url',
+    [('Darwin', '', '', "https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.4.6.tgz"),
+     ('Linux', 'ubuntu', '18.04',
+      "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.4.6.tgz"),
+     ('Windows', '', '', "https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-4.4.6.zip")])
+def test_mongod_url(monkeypatch: MonkeyPatch, platform_name: str, distro_name: str,
+                    distro_version: str, true_url: str) -> None:
+    """Test mongo version based on platform system."""
+    monkeypatch.setattr("platform.system", lambda: platform_name)
+    monkeypatch.setattr("distro.id", lambda: distro_name)
+    monkeypatch.setattr("distro.version", lambda: distro_version)
+    monkeypatch.setattr("distro.major_version", lambda: distro_version.split('.')[0])
+    assert MongodBinary(Path(tempfile.gettempdir())).url == true_url
+
+
+@mark.parametrize('platform_name, archive', [('Darwin', lazy_fixture('mongodb_archive_macos')),
+                                             ('Windows', lazy_fixture('mongodb_archive_windows'))])
+def test_unpack(monkeypatch: MonkeyPatch, platform_name: str, archive: IO[bytes]) -> None:
+    """Test unpacking mechanism based on archive format."""
+
+    directory: Path = Path(tempfile.gettempdir())
+
+    monkeypatch.setattr("platform.system", lambda: platform_name)
+    binary_test = MongodBinary(directory)
+    mongod_path = directory / binary_test.binary_name
+    # pylint: disable=protected-access
+    binary_test._MongodBinary__unpack(archive)  # type: ignore[attr-defined]
+    assert mongod_path.exists()
+    mongod_path.unlink()
diff --git a/tests/test_plugin.py b/tests/test_plugin.py
index ddf86ff..5ff292f 100644
--- a/tests/test_plugin.py
+++ b/tests/test_plugin.py
@@ -4,11 +4,9 @@
 from unittest.mock import Mock, patch
 
 import pytest
-from pytest import MonkeyPatch, Testdir, raises
+from pytest import Testdir
 
-from pytest_motor.plugin import _event_loop, _mongo_ver
-
-# pylint: disable=redefined-outer-name
+from pytest_motor.plugin import _event_loop
 
 test_files_directory = Path(__file__).parent.parent / 'test_data' / 'files'
 # yapf: disable
@@ -45,6 +43,7 @@ def test_event_loop() -> None:
 
 
 def test_new_port(testdir: Testdir, read_conftest: str) -> None:
+    # pylint: disable=redefined-outer-name
     """Test pytest_motor.plugin.new_port."""
     assert 'port_tests.py' in test_files.keys()
     testdir.makeconftest(read_conftest)
@@ -53,6 +52,7 @@ def test_new_port(testdir: Testdir, read_conftest: str) -> None:
 
 
 def test_mongod_binary_downloader(testdir: Testdir, read_conftest: str) -> None:
+    # pylint: disable=redefined-outer-name
     """Test pytest_motor.plugin.mongod_binary."""
     assert 'binary_downloader_tests.py' in test_files.keys()
     testdir.makeconftest(read_conftest)
@@ -61,6 +61,7 @@ def test_mongod_binary_downloader(testdir: Testdir, read_conftest: str) -> None:
 
 
 def test_integration_motor_client(testdir: Testdir, read_conftest: str) -> None:
+    # pylint: disable=redefined-outer-name
     """Test pytest_motor.plugin.motor_client."""
     assert 'server_info_test.py' in test_files.keys()
     testdir.makeconftest(read_conftest)
@@ -69,6 +70,7 @@ def test_integration_motor_client(testdir: Testdir, read_conftest: str) -> None:
 
 
 def test_integration_clients_independence(testdir: Testdir, read_conftest: str) -> None:
+    # pylint: disable=redefined-outer-name
     """Test pytest_motor.plugin.motor_client."""
     assert 'independence_tests.py' in test_files.keys()
     testdir.makeconftest(read_conftest)
@@ -77,21 +79,9 @@ def test_integration_clients_independence(testdir: Testdir, read_conftest: str)
 
 
 def test_integration_parametrized_test(testdir: Testdir, read_conftest: str) -> None:
+    # pylint: disable=redefined-outer-name
     """Test pytest_motor.plugin.motor_client."""
     assert 'paramatrized_test.py' in test_files.keys()
     testdir.makeconftest(read_conftest)
     testdir.makepyfile(test_files['paramatrized_test.py'].read_text())
     testdir.runpytest().assert_outcomes(passed=3)
-
-
-def test_mongo_ver(monkeypatch: MonkeyPatch) -> None:
-    """Test mongo version based on platform system."""
-    monkeypatch.setattr("platform.system", lambda: "Darwin")
-    assert _mongo_ver() == ("osx", "mongodb-macos-x86_64-4.4.6")
-
-    monkeypatch.setattr("platform.system", lambda: "Linux")
-    assert _mongo_ver() == ("linux", "mongodb-linux-x86_64-ubuntu1804-4.4.6")
-
-    monkeypatch.setattr("platform.system", lambda: "Windows")
-    with raises(Exception):
-        _mongo_ver()