From d7cb44af3c3cf84e84b219094b3fc97a8ed06c5c Mon Sep 17 00:00:00 2001 From: mhairifin Date: Fri, 9 Aug 2024 15:31:41 +0100 Subject: [PATCH 1/3] replace Path with PosixPath to fix Windows compatibility --- poetry.lock | 71 ++++++------------------------- wiremock/testing/testcontainer.py | 6 +-- 2 files changed, 16 insertions(+), 61 deletions(-) diff --git a/poetry.lock b/poetry.lock index ef20ef5..34e7a3f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,10 +1,9 @@ -# This file is automatically @generated by Poetry 1.4.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "black" version = "23.3.0" description = "The uncompromising code formatter." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -55,7 +54,6 @@ uvloop = ["uvloop (>=0.15.2)"] name = "cachetools" version = "5.3.0" description = "Extensible memoizing collections and decorators" -category = "dev" optional = false python-versions = "~=3.7" files = [ @@ -67,7 +65,6 @@ files = [ name = "certifi" version = "2022.12.7" description = "Python package for providing Mozilla's CA Bundle." -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -79,7 +76,6 @@ files = [ name = "chardet" version = "5.1.0" description = "Universal encoding detector for Python 3" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -91,7 +87,6 @@ files = [ name = "charset-normalizer" version = "3.1.0" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -category = "main" optional = false python-versions = ">=3.7.0" files = [ @@ -176,7 +171,6 @@ files = [ name = "click" version = "8.1.3" description = "Composable command line interface toolkit" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -192,7 +186,6 @@ importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ @@ -204,7 +197,6 @@ files = [ name = "coverage" version = "7.2.3" description = "Code coverage measurement for Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -271,7 +263,6 @@ toml = ["tomli"] name = "deprecation" version = "2.1.0" description = "A library to handle automated deprecations" -category = "main" optional = true python-versions = "*" files = [ @@ -286,7 +277,6 @@ packaging = "*" name = "distlib" version = "0.3.6" description = "Distribution utilities" -category = "dev" optional = false python-versions = "*" files = [ @@ -298,7 +288,6 @@ files = [ name = "docker" version = "6.1.0" description = "A Python library for the Docker Engine API." -category = "main" optional = true python-versions = ">=3.7" files = [ @@ -320,7 +309,6 @@ ssh = ["paramiko (>=2.4.3)"] name = "exceptiongroup" version = "1.1.1" description = "Backport of PEP 654 (exception groups)" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -335,7 +323,6 @@ test = ["pytest (>=6)"] name = "filelock" version = "3.12.0" description = "A platform independent file lock." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -351,7 +338,6 @@ testing = ["covdefaults (>=2.3)", "coverage (>=7.2.3)", "diff-cover (>=7.5)", "p name = "ghp-import" version = "2.1.0" description = "Copy your docs directly to the gh-pages branch." -category = "dev" optional = false python-versions = "*" files = [ @@ -369,7 +355,6 @@ dev = ["flake8", "markdown", "twine", "wheel"] name = "idna" version = "3.4" description = "Internationalized Domain Names in Applications (IDNA)" -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -381,7 +366,6 @@ files = [ name = "importlib-metadata" version = "6.5.1" description = "Read metadata from Python packages" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -402,7 +386,6 @@ testing = ["flake8 (<5)", "flufl.flake8", "importlib-resources (>=1.3)", "packag name = "importlib-resources" version = "5.12.0" description = "Read resources from Python packages" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -421,7 +404,6 @@ testing = ["flake8 (<5)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-chec name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -433,7 +415,6 @@ files = [ name = "jinja2" version = "3.1.2" description = "A very fast and expressive template engine." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -451,7 +432,6 @@ i18n = ["Babel (>=2.7)"] name = "markdown" version = "3.3.7" description = "Python implementation of Markdown." -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -469,7 +449,6 @@ testing = ["coverage", "pyyaml"] name = "markdown-include" version = "0.8.1" description = "A Python-Markdown extension which provides an 'include' function" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -487,7 +466,6 @@ tests = ["pytest"] name = "markupsafe" version = "2.1.3" description = "Safely add untrusted strings to HTML/XML markup." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -511,6 +489,16 @@ files = [ {file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac"}, {file = "MarkupSafe-2.1.3-cp311-cp311-win32.whl", hash = "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb"}, {file = "MarkupSafe-2.1.3-cp311-cp311-win_amd64.whl", hash = "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:f698de3fd0c4e6972b92290a45bd9b1536bffe8c6759c62471efaa8acb4c37bc"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aa57bd9cf8ae831a362185ee444e15a93ecb2e344c8e52e4d721ea3ab6ef1823"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ffcc3f7c66b5f5b7931a5aa68fc9cecc51e685ef90282f4a82f0f5e9b704ad11"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:47d4f1c5f80fc62fdd7777d0d40a2e9dda0a05883ab11374334f6c4de38adffd"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1f67c7038d560d92149c060157d623c542173016c4babc0c1913cca0564b9939"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:9aad3c1755095ce347e26488214ef77e0485a3c34a50c5a5e2471dff60b9dd9c"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:14ff806850827afd6b07a5f32bd917fb7f45b046ba40c57abdb636674a8b559c"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8f9293864fe09b8149f0cc42ce56e3f0e54de883a9de90cd427f191c346eb2e1"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-win32.whl", hash = "sha256:715d3562f79d540f251b99ebd6d8baa547118974341db04f5ad06d5ea3eb8007"}, + {file = "MarkupSafe-2.1.3-cp312-cp312-win_amd64.whl", hash = "sha256:1b8dd8c3fd14349433c79fa8abeb573a55fc0fdd769133baac1f5e07abf54aeb"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707"}, @@ -547,7 +535,6 @@ files = [ name = "mergedeep" version = "1.3.4" description = "A deep merge function for 🐍." -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -559,7 +546,6 @@ files = [ name = "mkdocs" version = "1.4.3" description = "Project documentation with Markdown." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -589,7 +575,6 @@ min-versions = ["babel (==2.9.0)", "click (==7.0)", "colorama (==0.4)", "ghp-imp name = "mypy-extensions" version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." -category = "dev" optional = false python-versions = ">=3.5" files = [ @@ -601,7 +586,6 @@ files = [ name = "packaging" version = "23.1" description = "Core utilities for Python packages" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -613,7 +597,6 @@ files = [ name = "pathspec" version = "0.11.1" description = "Utility library for gitignore style pattern matching of file paths." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -625,7 +608,6 @@ files = [ name = "platformdirs" version = "3.2.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -644,7 +626,6 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.2.2)", "pytest- name = "pluggy" version = "1.0.0" description = "plugin and hook calling mechanisms for python" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -663,7 +644,6 @@ testing = ["pytest", "pytest-benchmark"] name = "pyproject-api" version = "1.5.1" description = "API to interact with the python pyproject.toml based projects" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -683,7 +663,6 @@ testing = ["covdefaults (>=2.2.2)", "importlib-metadata (>=6)", "pytest (>=7.2.1 name = "pytest" version = "7.3.1" description = "pytest: simple powerful testing with Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -707,7 +686,6 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no name = "pytest-cov" version = "4.0.0" description = "Pytest plugin for measuring coverage." -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -726,7 +704,6 @@ testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtuale name = "pytest-cover" version = "3.0.0" description = "Pytest plugin for measuring coverage. Forked from `pytest-cov`." -category = "dev" optional = false python-versions = "*" files = [ @@ -741,7 +718,6 @@ pytest-cov = ">=2.0" name = "pytest-coverage" version = "0.0" description = "Pytest plugin for measuring coverage. Forked from `pytest-cov`." -category = "dev" optional = false python-versions = "*" files = [ @@ -756,7 +732,6 @@ pytest-cover = "*" name = "python-coveralls" version = "2.9.3" description = "Python interface to coveralls.io API\n" -category = "dev" optional = false python-versions = "*" files = [ @@ -774,7 +749,6 @@ six = "*" name = "python-dateutil" version = "2.8.2" description = "Extensions to the standard Python datetime module" -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" files = [ @@ -789,7 +763,6 @@ six = ">=1.5" name = "pywin32" version = "306" description = "Python for Window Extensions" -category = "main" optional = true python-versions = "*" files = [ @@ -813,7 +786,6 @@ files = [ name = "pyyaml" version = "6.0" description = "YAML parser and emitter for Python" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -863,7 +835,6 @@ files = [ name = "pyyaml-env-tag" version = "0.1" description = "A custom YAML tag for referencing environment variables in YAML files. " -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -878,7 +849,6 @@ pyyaml = "*" name = "requests" version = "2.28.2" description = "Python HTTP for Humans." -category = "main" optional = false python-versions = ">=3.7, <4" files = [ @@ -900,7 +870,6 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] name = "responses" version = "0.23.1" description = "A utility library for mocking out the `requests` Python library." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -922,7 +891,6 @@ tests = ["coverage (>=6.0.0)", "flake8", "mypy", "pytest (>=7.0.0)", "pytest-asy name = "six" version = "1.16.0" description = "Python 2 and 3 compatibility utilities" -category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" files = [ @@ -934,7 +902,6 @@ files = [ name = "testcontainers" version = "3.7.1" description = "Library provides lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container" -category = "main" optional = true python-versions = ">=3.7" files = [ @@ -968,7 +935,6 @@ selenium = ["selenium"] name = "tomli" version = "2.0.1" description = "A lil' TOML parser" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -980,7 +946,6 @@ files = [ name = "tox" version = "4.4.12" description = "tox is a generic virtualenv management and test command line tool" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1010,7 +975,6 @@ testing = ["build[virtualenv] (>=0.10)", "covdefaults (>=2.3)", "devpi-process ( name = "typed-ast" version = "1.5.4" description = "a fork of Python 2 and 3 ast modules with type comment support" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -1044,7 +1008,6 @@ files = [ name = "types-pyyaml" version = "6.0.12.9" description = "Typing stubs for PyYAML" -category = "dev" optional = false python-versions = "*" files = [ @@ -1056,7 +1019,6 @@ files = [ name = "typing-extensions" version = "4.5.0" description = "Backported and Experimental Type Hints for Python 3.7+" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1068,7 +1030,6 @@ files = [ name = "urllib3" version = "1.26.15" description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" files = [ @@ -1085,7 +1046,6 @@ socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] name = "virtualenv" version = "20.22.0" description = "Virtual Python Environment builder" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1107,7 +1067,6 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.3)", "coverage-enable-subprocess name = "watchdog" version = "3.0.0" description = "Filesystem events monitoring" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1147,7 +1106,6 @@ watchmedo = ["PyYAML (>=3.10)"] name = "websocket-client" version = "1.5.1" description = "WebSocket client for Python with low level API options" -category = "main" optional = true python-versions = ">=3.7" files = [ @@ -1164,7 +1122,6 @@ test = ["websockets"] name = "wheel" version = "0.40.0" description = "A built-package format for Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1179,7 +1136,6 @@ test = ["pytest (>=6.0.0)"] name = "wrapt" version = "1.15.0" description = "Module for decorators, wrappers and monkey patching." -category = "main" optional = true python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" files = [ @@ -1264,7 +1220,6 @@ files = [ name = "zipp" version = "3.15.0" description = "Backport of pathlib-compatible object wrapper for zip files" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1281,5 +1236,5 @@ testing = ["docker", "testcontainers"] [metadata] lock-version = "2.0" -python-versions = "^3.7 | ^3.8 | ^3.9 | ^3.10 | ^3.11" -content-hash = "5b762b85c489532b28b3e77cede06094b97478e2ffbdbc33010b9c39c2a931d4" +python-versions = "^3.7 | ^3.8 | ^3.9 | ^3.10 | ^3.11" +content-hash = "797379f6dd32687c935a7603dfaca39832b6748e8823d4402922ad7a94329851" diff --git a/wiremock/testing/testcontainer.py b/wiremock/testing/testcontainer.py index 2f64cda..80c4665 100644 --- a/wiremock/testing/testcontainer.py +++ b/wiremock/testing/testcontainer.py @@ -4,7 +4,7 @@ import tempfile import time from contextlib import contextmanager -from pathlib import Path +from pathlib import Path, PurePosixPath from typing import Any, Dict, Generator, List, Optional, Tuple, Union from urllib.parse import urljoin @@ -131,7 +131,7 @@ def copy_mappings_to_container(self) -> None: """ self.copy_files_to_container( - configs=self.mapping_stubs, container_dir_path=Path(f"{self.MAPPINGS_DIR}") + configs=self.mapping_stubs, container_dir_path=PurePosixPath(f"{self.MAPPINGS_DIR}") ) def copy_mapping_files_to_container(self) -> None: @@ -140,7 +140,7 @@ def copy_mapping_files_to_container(self) -> None: the configured FILES_DIR """ self.copy_files_to_container( - configs=self.mapping_files, container_dir_path=Path(f"{self.FILES_DIR}") + configs=self.mapping_files, container_dir_path=PurePosixPath(f"{self.FILES_DIR}") ) def server_running(self, retry_count: int = 3, retry_delay: int = 1) -> bool: From b13d214cbe0a0f2c5c00f4bac30f4eb7451c6f0a Mon Sep 17 00:00:00 2001 From: mhairifin Date: Tue, 13 Aug 2024 09:35:12 +0100 Subject: [PATCH 2/3] Convert to posix path at point of write --- wiremock/testing/testcontainer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wiremock/testing/testcontainer.py b/wiremock/testing/testcontainer.py index 80c4665..518113f 100644 --- a/wiremock/testing/testcontainer.py +++ b/wiremock/testing/testcontainer.py @@ -4,7 +4,7 @@ import tempfile import time from contextlib import contextmanager -from pathlib import Path, PurePosixPath +from pathlib import Path from typing import Any, Dict, Generator, List, Optional, Tuple, Union from urllib.parse import urljoin @@ -94,7 +94,7 @@ def with_command(self, cmd: Optional[str] = None) -> "WireMockContainer": def copy_file_to_container(self, host_path: Path, container_path: Path) -> None: with open(host_path, "rb") as fp: self.get_wrapped_container().put_archive( - path=container_path, data=fp.read() + path=container_path.as_posix(), data=fp.read() ) def copy_files_to_container( @@ -131,7 +131,7 @@ def copy_mappings_to_container(self) -> None: """ self.copy_files_to_container( - configs=self.mapping_stubs, container_dir_path=PurePosixPath(f"{self.MAPPINGS_DIR}") + configs=self.mapping_stubs, container_dir_path=Path(f"{self.MAPPINGS_DIR}") ) def copy_mapping_files_to_container(self) -> None: @@ -140,7 +140,7 @@ def copy_mapping_files_to_container(self) -> None: the configured FILES_DIR """ self.copy_files_to_container( - configs=self.mapping_files, container_dir_path=PurePosixPath(f"{self.FILES_DIR}") + configs=self.mapping_files, container_dir_path=Path(f"{self.FILES_DIR}") ) def server_running(self, retry_count: int = 3, retry_delay: int = 1) -> bool: From fc2df60d0ff13e22f2cf5995d11596f83869a0ea Mon Sep 17 00:00:00 2001 From: mhairifin Date: Tue, 13 Aug 2024 09:35:34 +0100 Subject: [PATCH 3/3] test to ensure container write path is posix formatted --- tests/test_containers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_containers.py b/tests/test_containers.py index cf3c193..cbcde56 100644 --- a/tests/test_containers.py +++ b/tests/test_containers.py @@ -321,7 +321,7 @@ def test_copy_file_to_container(mock_get_container: Mock, tmp_path: Path): # Assert mock_get_container.return_value.put_archive.assert_called_once_with( - path=Path(wm.MAPPINGS_DIR), data=b'{"foo": "bar"}' + path=Path(wm.MAPPINGS_DIR).as_posix(), data=b'{"foo": "bar"}' )