Compare commits
43 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6284bcb2ae | ||
|
|
97a2eae8f8 |
||
|
|
59028c68ca |
||
|
|
ac1b919849 | ||
|
|
30fb5f718b | ||
|
|
9e46e4c4fd |
||
|
|
67b30a0a79 |
||
|
|
09bc2b79dd |
||
|
|
e3e917327c | ||
|
|
fa440ae601 | ||
|
|
b2e70df494 |
||
|
|
2b8d8e65f6 | ||
|
|
f4dcc0d584 |
||
|
|
00b3af9077 | ||
|
|
20390fcfa4 |
||
|
|
0a1e002267 |
||
|
|
b4dfcf11c4 |
||
|
|
c6396ab5c8 |
||
|
|
fb047b25f4 |
||
|
|
3ffafd84a9 |
||
|
|
65d0faba7b | ||
|
|
447ed9f012 |
||
|
|
0de26dad4e |
||
|
|
3688ce2b9e |
||
|
|
49ac3f9e07 |
||
|
|
40a0e17c91 |
||
|
|
780e4b3ba4 |
||
|
|
69ddae7d52 |
||
|
|
ae95f0ff00 |
||
|
|
a48f6abe3f |
||
|
|
4510cadc3a |
||
|
|
d78ad0e575 |
||
|
|
512d903b07 |
||
|
|
8f124aa453 |
||
|
|
e9292d008e |
||
|
|
e55893e218 |
||
|
|
e996983cd2 |
||
|
|
61f496a6d7 |
||
|
|
53881cd75a |
||
|
|
a039b9ba8f | ||
|
|
c24d7fcf28 | ||
|
|
403a9e4065 |
||
|
|
ef575d981c |
6 changed files with 201 additions and 162 deletions
22
.gitignore
vendored
22
.gitignore
vendored
|
|
@ -8,4 +8,24 @@
|
|||
/community.docker-2.5.0.tar.gz
|
||||
/community.docker-2.5.1.tar.gz
|
||||
/community.docker-2.6.0.tar.gz
|
||||
/community.docker-2.7.1.tar.gz
|
||||
/community.docker-2.7.0.tar.gz
|
||||
/community.docker-3.0.0.tar.gz
|
||||
/community.docker-3.0.1.tar.gz
|
||||
/community.docker-3.0.2.tar.gz
|
||||
/community.docker-3.1.0.tar.gz
|
||||
/community.docker-3.2.0.tar.gz
|
||||
/community.docker-3.2.2.tar.gz
|
||||
/community.docker-3.3.0.tar.gz
|
||||
/community.docker-3.3.1.tar.gz
|
||||
/community.docker-3.3.2.tar.gz
|
||||
/community.docker-3.4.0.tar.gz
|
||||
/community.docker-3.4.2.tar.gz
|
||||
/community.docker-3.4.3.tar.gz
|
||||
/community.docker-3.4.5.tar.gz
|
||||
/community.docker-3.4.6.tar.gz
|
||||
/community.docker-3.5.0.tar.gz
|
||||
/community.docker-3.12.2.tar.gz
|
||||
/community.docker-3.13.0.tar.gz
|
||||
/community.docker-4.1.0.tar.gz
|
||||
/community.docker-4.7.0.tar.gz
|
||||
/community.docker-5.0.3.tar.gz
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
# See https://src.fedoraproject.org/rpms/ansible/pull-request/19#comment-90820 for more information.
|
||||
addFilter("E: non-executable-script")
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
%global collection_namespace community
|
||||
%global collection_name docker
|
||||
%global forgeurl https://github.com/ansible-collections/%{collection_namespace}.%{collection_name}
|
||||
|
||||
# Only run tests where %%generate_buildrequires and test deps are available.
|
||||
# ansible-core is built for alternative Python stacks in RHEL which do not have
|
||||
# the necessary test deps packaged.
|
||||
%if %{defined fedora}
|
||||
%bcond_without tests
|
||||
%else
|
||||
|
|
@ -10,40 +7,87 @@
|
|||
%endif
|
||||
|
||||
|
||||
Name: ansible-collection-%{collection_namespace}-%{collection_name}
|
||||
Version: 2.7.1
|
||||
%global tag %{version}
|
||||
%forgemeta
|
||||
Release: 1%{?dist}
|
||||
Name: ansible-collection-community-docker
|
||||
Version: 5.0.3
|
||||
Release: 2%{?dist}
|
||||
Summary: Ansible modules and plugins for working with Docker
|
||||
|
||||
# All files are GPL-3.0-or-later except plugins/module_utils/_version.py.
|
||||
License: GPL-3.0-or-later and Python
|
||||
URL: %{ansible_collection_url}
|
||||
Source0: %{forgesource}
|
||||
Source1: %{name}.rpmlintrc
|
||||
# Downstream only patch to remove tests, CI configuration, and other
|
||||
# unnecessary development files from the built collection.
|
||||
# All files are GPL-3.0-or-later, except the following files, which are originally
|
||||
# from the Docker Python SDK.
|
||||
# rg --pcre2 -g '!tests/sanity/extra/licenses.py' 'SPDX-License-Identifier: (?!GPL-3\.0-or-later)' | sort | sed 's|^|# |'
|
||||
#
|
||||
# plugins/module_utils/_api/api/client.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/api/daemon.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/auth.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/constants.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/credentials/constants.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/credentials/errors.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/credentials/store.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/credentials/utils.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/errors.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/_import_helper.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/tls.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/transport/basehttpadapter.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/transport/npipeconn.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/transport/npipesocket.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/transport/sshconn.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/transport/ssladapter.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/transport/unixconn.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/types/daemon.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/utils/build.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/utils/config.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/utils/decorators.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/utils/fnmatch.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/utils/json_stream.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/utils/ports.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/utils/proxy.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/utils/socket.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# plugins/module_utils/_api/utils/utils.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/api/test_client.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/fake_api.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/fake_stat.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/test_auth.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/test_errors.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/transport/test_sshconn.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/transport/test_ssladapter.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/utils/test_build.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/utils/test_config.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/utils/testdata/certs/ca.pem:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/utils/testdata/certs/cert.pem:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/utils/testdata/certs/key.pem:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/utils/test_decorators.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/utils/test_json_stream.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/utils/test_ports.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/utils/test_proxy.py:# SPDX-License-Identifier: Apache-2.0
|
||||
# tests/unit/plugins/module_utils/_api/utils/test_utils.py:# SPDX-License-Identifier: Apache-2.0
|
||||
License: GPL-3.0-or-later AND Apache-2.0
|
||||
URL: %{ansible_collection_url community docker}
|
||||
%global forgeurl https://github.com/ansible-collections/community.docker
|
||||
Source0: %{forgeurl}/archive/%{version}/community.docker-%{version}.tar.gz
|
||||
Patch0: build_ignore-unnecessary-files.patch
|
||||
Patch1: https://github.com/ansible-collections/community.docker/pull/433.patch#/remove-python-mock.patch
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
BuildRequires: ansible-packaging
|
||||
%if %{with tests}
|
||||
BuildRequires: ansible-packaging-tests
|
||||
BuildRequires: %{py3_dist docker}
|
||||
BuildRequires: ansible-collection(community.library_inventory_filtering_v1)
|
||||
BuildRequires: ansible-collection(community.internal_test_tools)
|
||||
BuildRequires: %{py3_dist requests}
|
||||
%endif
|
||||
|
||||
# This collection contains vendored code from the Docker Python SDK.
|
||||
Provides: bundled(python3dist(docker))
|
||||
|
||||
|
||||
%description
|
||||
%{name} provides the %{collection_namespace}.%{collection_name}
|
||||
Ansible collection. The collection includes Ansible modules and plugins for
|
||||
working with Docker.
|
||||
ansible-collection-community-docker provides the community.docker Ansible
|
||||
collection. The collection includes Ansible modules and plugins for working
|
||||
with Docker.
|
||||
|
||||
|
||||
%prep
|
||||
%forgeautosetup -p1
|
||||
%autosetup -p1 -n community.docker-%{version}
|
||||
find -type f ! -executable -name '*.py' -print -exec sed -i -e '1{\@^#!.*@d}' '{}' +
|
||||
|
||||
|
||||
|
|
@ -57,19 +101,114 @@ find -type f ! -executable -name '*.py' -print -exec sed -i -e '1{\@^#!.*@d}' '{
|
|||
|
||||
%check
|
||||
%if %{with tests}
|
||||
%ansible_test_unit
|
||||
%ansible_test_unit -c community.library_inventory_filtering_v1 -c community.internal_test_tools
|
||||
%endif
|
||||
|
||||
|
||||
%files
|
||||
%license COPYING PSF-license.txt
|
||||
%doc README.md CHANGELOG.rst
|
||||
%{ansible_collection_files}
|
||||
%files -f %{ansible_collection_filelist}
|
||||
%license COPYING LICENSES REUSE.toml
|
||||
%doc README.md CHANGELOG.rst*
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Aug 19 2022 Maxwell G <gotmax@e.email> - 2.7.1-1
|
||||
- Update to 2.7.1.
|
||||
* Fri Jan 16 2026 Fedora Release Engineering <releng@fedoraproject.org> - 5.0.3-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild
|
||||
|
||||
* Fri Dec 05 2025 Maxwell G <maxwell@gtmx.me> - 5.0.3-1
|
||||
- Update to 5.0.3. Fixes rhbz#2401383.
|
||||
|
||||
* Sat Aug 30 2025 Maxwell G <maxwell@gtmx.me> - 4.7.0-1
|
||||
- Update to 4.7.0. Fixes rhbz#2332649.
|
||||
|
||||
* Wed Jul 23 2025 Fedora Release Engineering <releng@fedoraproject.org> - 4.1.0-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
|
||||
|
||||
* Thu Jan 16 2025 Fedora Release Engineering <releng@fedoraproject.org> - 4.1.0-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
|
||||
|
||||
* Tue Nov 26 2024 Maxwell G <maxwell@gtmx.me> - 4.1.0-1
|
||||
- Update to 4.1.0. Fixes rhbz#2319299.
|
||||
|
||||
* Fri Oct 11 2024 Maxwell G <maxwell@gtmx.me> - 3.13.0-1
|
||||
- Update to 3.13.0. Fixes rhbz#2316730.
|
||||
|
||||
* Thu Sep 26 2024 Maxwell G <maxwell@gtmx.me> - 3.12.2-1
|
||||
- Update to 3.12.2. Fixes rhbz#2242856.
|
||||
|
||||
* Wed Jul 17 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.5.0-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
|
||||
|
||||
* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.5.0-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
|
||||
|
||||
* Sun Jan 21 2024 Maxwell G <maxwell@gtmx.me> - 3.5.0-1
|
||||
- Update to 3.5.0.
|
||||
|
||||
* Fri Jan 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.6-4
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
|
||||
|
||||
* Tue Jul 25 2023 Maxwell G <maxwell@gtmx.me> - 3.4.6-3
|
||||
- Fix FTBFS. Closes rhbz#2215512.
|
||||
|
||||
* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.6-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
|
||||
|
||||
* Sat May 20 2023 Maxwell G <maxwell@gtmx.me> - 3.4.6-1
|
||||
- Update to 3.4.6.
|
||||
|
||||
* Sat May 06 2023 Maxwell G <maxwell@gtmx.me> - 3.4.5-1
|
||||
- Update to 3.4.5. Fixes rhbz#2181482.
|
||||
|
||||
* Fri Mar 31 2023 Maxwell G <maxwell@gtmx.me> - 3.4.3-1
|
||||
- Update to 3.4.3. Fixes rhbz#2181482.
|
||||
|
||||
* Wed Mar 01 2023 Maxwell G <maxwell@gtmx.me> - 3.4.2-1
|
||||
- Update to 3.4.2. Fixes rhbz#2172008.
|
||||
|
||||
* Tue Jan 24 2023 Maxwell G <gotmax@e.email> - 3.4.0-1
|
||||
- Update to 3.4.0. Fixes rhbz#2161016.
|
||||
|
||||
* Wed Jan 18 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.2-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
|
||||
|
||||
* Sat Dec 10 2022 Maxwell G <gotmax@e.email> - 3.3.2-1
|
||||
- Update to 3.3.2. Fixes rhbz#2150678.
|
||||
|
||||
* Fri Dec 09 2022 Maxwell G <gotmax@e.email> - 3.3.1-1
|
||||
- Update to 3.3.1. Fixes rhbz#2150678.
|
||||
|
||||
* Sat Dec 03 2022 Maxwell G <gotmax@e.email> - 3.3.0-1
|
||||
- Update to 3.3.0.
|
||||
|
||||
* Tue Nov 29 2022 Maxwell G <gotmax@e.email> - 3.2.2-1
|
||||
- Update to 3.2.2.
|
||||
|
||||
* Thu Nov 03 2022 Maxwell G <gotmax@e.email> - 3.2.0-2
|
||||
- Remove unexpanded macros from %%description
|
||||
- Handle .reuse/dep5
|
||||
|
||||
* Wed Nov 02 2022 Maxwell G <gotmax@e.email> - 3.2.0-1
|
||||
- Update to 3.2.0. Fixes rhbz#2139344.
|
||||
|
||||
* Thu Sep 08 2022 Maxwell G <gotmax@e.email> - 3.1.0-1
|
||||
- Update to 3.1.0. Fixes rhbz#2125151.
|
||||
|
||||
* Tue Aug 16 2022 Maxwell G <gotmax@e.email> - 3.0.2-1
|
||||
- Update to 3.0.2.
|
||||
|
||||
* Tue Aug 16 2022 Maxwell G <gotmax@e.email> - 3.0.1-1
|
||||
- Update to 3.0.1.
|
||||
|
||||
* Fri Aug 12 2022 Maxwell G <gotmax@e.email> - 3.0.0-1
|
||||
- Update to 3.0.0 (rhbz#2105298).
|
||||
- Follow Fedora's new licensing guidelines
|
||||
|
||||
* Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.7.0-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
||||
|
||||
* Sat Jul 02 2022 Maxwell G <gotmax@e.email> - 2.7.0-1
|
||||
- Update to 2.7.0. Fixes rhbz#2103337.
|
||||
- Fix shebangs
|
||||
|
||||
* Wed May 25 2022 Maxwell G <gotmax@e.email> - 2.6.0-1
|
||||
- Update to 2.6.0. Fixes rhbz#2089991.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
diff -Naur a/galaxy.yml b/galaxy.yml
|
||||
--- a/galaxy.yml 2022-04-25 14:32:27.000000000 -0500
|
||||
+++ b/galaxy.yml 2022-04-29 21:07:55.917219135 -0500
|
||||
@@ -18,3 +18,8 @@
|
||||
--- a/galaxy.yml
|
||||
+++ b/galaxy.yml
|
||||
@@ -25,4 +25,15 @@
|
||||
build_ignore:
|
||||
# https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#ignoring-files-and-folders
|
||||
- .gitignore
|
||||
- changelogs/.plugin-cache.yaml
|
||||
|
|
@ -10,3 +11,9 @@ diff -Naur a/galaxy.yml b/galaxy.yml
|
|||
+ - .azure-pipelines
|
||||
+ - changelogs/fragments/.keep
|
||||
+ - docs
|
||||
+ # We install these files with %license and %doc. We don't want them duplicated.
|
||||
+ - "CHANGELOG.rst*"
|
||||
+ - README.md
|
||||
+ - COPYING
|
||||
+ - LICENSES
|
||||
+ - REUSE.toml
|
||||
|
|
|
|||
|
|
@ -1,125 +0,0 @@
|
|||
From 7e9eee69c273515129cc0ac0e425b4b2c7da9263 Mon Sep 17 00:00:00 2001
|
||||
From: Maxwell G <gotmax@e.email>
|
||||
Date: Thu, 28 Jul 2022 13:57:18 +0200
|
||||
Subject: [PATCH 1/2] Prefer unitest.mock by using compat.mock
|
||||
|
||||
`mock` is a backport of the `unittest.mock` module from the stdlib, and
|
||||
there's no reason to use it on newer Python versions. `mock` is deprecated
|
||||
in Fedora, so I figured I'd propose this here before downstream patching
|
||||
our ansible-collection-community-docker package.
|
||||
---
|
||||
tests/unit/plugins/inventory/test_docker_containers.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/unit/plugins/inventory/test_docker_containers.py b/tests/unit/plugins/inventory/test_docker_containers.py
|
||||
index 1c831b21..74721bfe 100644
|
||||
--- a/tests/unit/plugins/inventory/test_docker_containers.py
|
||||
+++ b/tests/unit/plugins/inventory/test_docker_containers.py
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
-from mock import MagicMock
|
||||
+from ansible_collections.community.docker.tests.unit.compat.mock import MagicMock
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible.errors import AnsibleError
|
||||
|
||||
From 0efaff6a01c113980a70b92e93bdadd7237a7949 Mon Sep 17 00:00:00 2001
|
||||
From: Maxwell G <gotmax@e.email>
|
||||
Date: Thu, 28 Jul 2022 14:15:53 +0200
|
||||
Subject: [PATCH 2/2] Remove compat.mock code for older Python 3 versions
|
||||
|
||||
This removes compatibility for older versions of Python 3 that are no
|
||||
longer supported.
|
||||
---
|
||||
tests/unit/compat/mock.py | 79 ---------------------------------------
|
||||
1 file changed, 79 deletions(-)
|
||||
|
||||
diff --git a/tests/unit/compat/mock.py b/tests/unit/compat/mock.py
|
||||
index f8f565dc..515b94a3 100644
|
||||
--- a/tests/unit/compat/mock.py
|
||||
+++ b/tests/unit/compat/mock.py
|
||||
@@ -28,82 +28,3 @@
|
||||
from mock import *
|
||||
except ImportError:
|
||||
print('You need the mock library installed on python2.x to run tests')
|
||||
-
|
||||
-
|
||||
-# Prior to 3.4.4, mock_open cannot handle binary read_data
|
||||
-if sys.version_info >= (3,) and sys.version_info < (3, 4, 4):
|
||||
- file_spec = None
|
||||
-
|
||||
- def _iterate_read_data(read_data):
|
||||
- # Helper for mock_open:
|
||||
- # Retrieve lines from read_data via a generator so that separate calls to
|
||||
- # readline, read, and readlines are properly interleaved
|
||||
- sep = b'\n' if isinstance(read_data, bytes) else '\n'
|
||||
- data_as_list = [l + sep for l in read_data.split(sep)]
|
||||
-
|
||||
- if data_as_list[-1] == sep:
|
||||
- # If the last line ended in a newline, the list comprehension will have an
|
||||
- # extra entry that's just a newline. Remove this.
|
||||
- data_as_list = data_as_list[:-1]
|
||||
- else:
|
||||
- # If there wasn't an extra newline by itself, then the file being
|
||||
- # emulated doesn't have a newline to end the last line remove the
|
||||
- # newline that our naive format() added
|
||||
- data_as_list[-1] = data_as_list[-1][:-1]
|
||||
-
|
||||
- for line in data_as_list:
|
||||
- yield line
|
||||
-
|
||||
- def mock_open(mock=None, read_data=''):
|
||||
- """
|
||||
- A helper function to create a mock to replace the use of `open`. It works
|
||||
- for `open` called directly or used as a context manager.
|
||||
-
|
||||
- The `mock` argument is the mock object to configure. If `None` (the
|
||||
- default) then a `MagicMock` will be created for you, with the API limited
|
||||
- to methods or attributes available on standard file handles.
|
||||
-
|
||||
- `read_data` is a string for the `read` methoddline`, and `readlines` of the
|
||||
- file handle to return. This is an empty string by default.
|
||||
- """
|
||||
- def _readlines_side_effect(*args, **kwargs):
|
||||
- if handle.readlines.return_value is not None:
|
||||
- return handle.readlines.return_value
|
||||
- return list(_data)
|
||||
-
|
||||
- def _read_side_effect(*args, **kwargs):
|
||||
- if handle.read.return_value is not None:
|
||||
- return handle.read.return_value
|
||||
- return type(read_data)().join(_data)
|
||||
-
|
||||
- def _readline_side_effect():
|
||||
- if handle.readline.return_value is not None:
|
||||
- while True:
|
||||
- yield handle.readline.return_value
|
||||
- for line in _data:
|
||||
- yield line
|
||||
-
|
||||
- global file_spec
|
||||
- if file_spec is None:
|
||||
- import _io
|
||||
- file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))))
|
||||
-
|
||||
- if mock is None:
|
||||
- mock = MagicMock(name='open', spec=open)
|
||||
-
|
||||
- handle = MagicMock(spec=file_spec)
|
||||
- handle.__enter__.return_value = handle
|
||||
-
|
||||
- _data = _iterate_read_data(read_data)
|
||||
-
|
||||
- handle.write.return_value = None
|
||||
- handle.read.return_value = None
|
||||
- handle.readline.return_value = None
|
||||
- handle.readlines.return_value = None
|
||||
-
|
||||
- handle.read.side_effect = _read_side_effect
|
||||
- handle.readline.side_effect = _readline_side_effect()
|
||||
- handle.readlines.side_effect = _readlines_side_effect
|
||||
-
|
||||
- mock.return_value = handle
|
||||
- return mock
|
||||
2
sources
2
sources
|
|
@ -1 +1 @@
|
|||
SHA512 (community.docker-2.7.1.tar.gz) = 4b0b3bd123729d35fbb70c7ddc90eb67154e17e53762be9a9ccc4cf63081b4a4f4e73a050a881d56bd13cd119e14785259777e2caf64a89243403eec8e99d8ea
|
||||
SHA512 (community.docker-5.0.3.tar.gz) = a4fd0c49eaf6b09f1831f007a042cc03202b4e1767dbd677bc00f89012d50ed5487bd4b94276e4b4b553d4a46504ec35a034267d20ed762a79caa169c1b35633
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue