pytest-services 2.2.0__tar.gz → 2.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pytest_services-2.2.2/.github/workflows/deploy.yml +64 -0
- pytest_services-2.2.2/.github/workflows/test.yml +69 -0
- pytest_services-2.2.2/.readthedocs.yaml +8 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/AUTHORS.rst +2 -1
- {pytest-services-2.2.0 → pytest_services-2.2.2}/CHANGES.rst +10 -0
- pytest_services-2.2.2/PKG-INFO +414 -0
- pytest_services-2.2.2/RELEASING.rst +12 -0
- pytest_services-2.2.2/pyproject.toml +5 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services/__init__.py +1 -1
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services/gui.py.orig +2 -2
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services/locks.py +14 -3
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services/mysql.py +17 -10
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services/service.py +2 -2
- pytest_services-2.2.2/pytest_services.egg-info/PKG-INFO +414 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services.egg-info/SOURCES.txt +4 -5
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services.egg-info/entry_points.txt +0 -1
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services.egg-info/requires.txt +0 -1
- pytest_services-2.2.2/requirements-testing.txt +3 -0
- pytest_services-2.2.2/setup.cfg +4 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/setup.py +16 -23
- pytest_services-2.2.2/tox.ini +17 -0
- pytest-services-2.2.0/.travis.yml +0 -28
- pytest-services-2.2.0/DEPENDENCIES +0 -2
- pytest-services-2.2.0/MANIFEST.in +0 -4
- pytest-services-2.2.0/Makefile +0 -27
- pytest-services-2.2.0/PKG-INFO +0 -385
- pytest-services-2.2.0/pyproject.toml +0 -3
- pytest-services-2.2.0/pytest_services.egg-info/PKG-INFO +0 -385
- pytest-services-2.2.0/requirements-testing.txt +0 -7
- pytest-services-2.2.0/setup.cfg +0 -10
- pytest-services-2.2.0/tox.ini +0 -41
- {pytest-services-2.2.0 → pytest_services-2.2.2}/.coveragerc +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/.gitignore +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/LICENSE.txt +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/README.rst +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/docs/Makefile +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/docs/api/index.rst +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/docs/conf.py +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/docs/index.rst +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services/django_settings.py +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services/folders.py +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services/log.py +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services/memcached.py +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services/plugin.py +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services/process.py +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services/xvfb.py +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services.egg-info/dependency_links.txt +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/pytest_services.egg-info/top_level.txt +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/tests/__init__.py +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/tests/conftest.py +0 -0
- {pytest-services-2.2.0 → pytest_services-2.2.2}/tests/test_plugin.py +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: deploy
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
version:
|
|
7
|
+
description: 'Release version'
|
|
8
|
+
required: true
|
|
9
|
+
default: '1.2.3'
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
|
|
13
|
+
package:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
# Required by attest-build-provenance-github.
|
|
16
|
+
permissions:
|
|
17
|
+
id-token: write
|
|
18
|
+
attestations: write
|
|
19
|
+
env:
|
|
20
|
+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- name: Build and Check Package
|
|
26
|
+
uses: hynek/build-and-inspect-python-package@v2.13.0
|
|
27
|
+
with:
|
|
28
|
+
attest-build-provenance-github: 'true'
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
deploy:
|
|
32
|
+
needs: package
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
environment: PyPI
|
|
35
|
+
permissions:
|
|
36
|
+
id-token: write # For PyPI trusted publishers.
|
|
37
|
+
contents: write # For tag and release notes.
|
|
38
|
+
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@v4
|
|
41
|
+
|
|
42
|
+
- name: Download Package
|
|
43
|
+
uses: actions/download-artifact@v4
|
|
44
|
+
with:
|
|
45
|
+
name: Packages
|
|
46
|
+
path: dist
|
|
47
|
+
|
|
48
|
+
- name: Publish package to PyPI
|
|
49
|
+
uses: pypa/gh-action-pypi-publish@v1.12.4
|
|
50
|
+
with:
|
|
51
|
+
attestations: true
|
|
52
|
+
|
|
53
|
+
- name: Push tag
|
|
54
|
+
run: |
|
|
55
|
+
git config user.name "pytest bot"
|
|
56
|
+
git config user.email "pytestbot@gmail.com"
|
|
57
|
+
git tag --annotate --message=v${{ github.event.inputs.version }} v${{ github.event.inputs.version }} ${{ github.sha }}
|
|
58
|
+
git push origin v${{ github.event.inputs.version }}
|
|
59
|
+
|
|
60
|
+
- name: GitHub Release
|
|
61
|
+
uses: softprops/action-gh-release@v2
|
|
62
|
+
with:
|
|
63
|
+
files: dist/*
|
|
64
|
+
tag_name: v${{ github.event.inputs.version }}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
- "test-me-*"
|
|
8
|
+
|
|
9
|
+
pull_request:
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
concurrency:
|
|
13
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
14
|
+
cancel-in-progress: true
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
|
|
18
|
+
package:
|
|
19
|
+
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
|
|
22
|
+
permissions:
|
|
23
|
+
id-token: write
|
|
24
|
+
attestations: write
|
|
25
|
+
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
- name: Build and Check Package
|
|
29
|
+
uses: hynek/build-and-inspect-python-package@v2.13.0
|
|
30
|
+
|
|
31
|
+
test:
|
|
32
|
+
needs: [package]
|
|
33
|
+
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
|
|
36
|
+
strategy:
|
|
37
|
+
fail-fast: false
|
|
38
|
+
matrix:
|
|
39
|
+
python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
40
|
+
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v4
|
|
43
|
+
|
|
44
|
+
- name: Download Package
|
|
45
|
+
uses: actions/download-artifact@v4
|
|
46
|
+
with:
|
|
47
|
+
name: Packages
|
|
48
|
+
path: dist
|
|
49
|
+
|
|
50
|
+
- name: Set up Python
|
|
51
|
+
uses: actions/setup-python@v5
|
|
52
|
+
with:
|
|
53
|
+
python-version: ${{ matrix.python }}
|
|
54
|
+
allow-prereleases: true
|
|
55
|
+
|
|
56
|
+
- name: System dependencies
|
|
57
|
+
run: |
|
|
58
|
+
sudo apt-get update
|
|
59
|
+
sudo apt-get install xvfb python3-dev libmemcached-dev libmysqlclient-dev memcached libmemcached-tools
|
|
60
|
+
|
|
61
|
+
- name: Install tox
|
|
62
|
+
run: |
|
|
63
|
+
python -m pip install --upgrade pip
|
|
64
|
+
pip install tox
|
|
65
|
+
|
|
66
|
+
- name: Test
|
|
67
|
+
shell: bash
|
|
68
|
+
run: |
|
|
69
|
+
tox run -e py --installpkg `find dist/*.tar.gz`
|
|
@@ -10,6 +10,7 @@ These people have contributed to `pytest-services`, in alphabetical order:
|
|
|
10
10
|
* `Dmitrijs Milajevs <dimazest@gmail.com>`_
|
|
11
11
|
* `Jason R. Coombs <jaraco@jaraco.com>`_
|
|
12
12
|
* `Joep van Dijken <joepvandijken@github.com>`_
|
|
13
|
+
* `Magnus Staberg <magnus@staberg.io>`_
|
|
14
|
+
* `Michael Shriver <mshriver@redhat.com>`_
|
|
13
15
|
* `Oleg Pidsadnyi <oleg.pidsadnyi@gmail.com>`_
|
|
14
16
|
* `Zac Hatfield-Dodds <zac@zhd.dev>`_
|
|
15
|
-
* `Magnus Staberg <magnus@staberg.io>`_
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
2.2.2
|
|
5
|
+
-----
|
|
6
|
+
|
|
7
|
+
- #47: Replace ``distutils.spawn.find_executable`` with ``shutil.which``. The package ``distutils`` is deprecated.
|
|
8
|
+
|
|
9
|
+
2.2.1
|
|
10
|
+
-----
|
|
11
|
+
|
|
12
|
+
- #42: Retry on ``zc.lockfile.LockError`` in ``file_lock``, use existing timeout kwarg (mshriver)
|
|
13
|
+
|
|
4
14
|
2.2.0
|
|
5
15
|
-----
|
|
6
16
|
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pytest-services
|
|
3
|
+
Version: 2.2.2
|
|
4
|
+
Summary: Services plugin for pytest testing framework
|
|
5
|
+
Home-page: https://github.com/pytest-dev/pytest-services
|
|
6
|
+
Author: Anatoly Bubenkov, Paylogic International and others
|
|
7
|
+
Author-email: bubenkoff@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Development Status :: 6 - Mature
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Operating System :: POSIX
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
14
|
+
Classifier: Topic :: Software Development :: Testing
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
+
Classifier: Topic :: Utilities
|
|
17
|
+
Classifier: Programming Language :: Python :: 2
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/x-rst
|
|
27
|
+
License-File: LICENSE.txt
|
|
28
|
+
License-File: AUTHORS.rst
|
|
29
|
+
Requires-Dist: requests
|
|
30
|
+
Requires-Dist: psutil
|
|
31
|
+
Requires-Dist: pytest
|
|
32
|
+
Requires-Dist: zc.lockfile>=2.0
|
|
33
|
+
Dynamic: author
|
|
34
|
+
Dynamic: author-email
|
|
35
|
+
Dynamic: classifier
|
|
36
|
+
Dynamic: description
|
|
37
|
+
Dynamic: description-content-type
|
|
38
|
+
Dynamic: home-page
|
|
39
|
+
Dynamic: license
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
Dynamic: requires-dist
|
|
42
|
+
Dynamic: requires-python
|
|
43
|
+
Dynamic: summary
|
|
44
|
+
|
|
45
|
+
Services plugin for pytest testing framework
|
|
46
|
+
============================================
|
|
47
|
+
|
|
48
|
+
.. image:: https://img.shields.io/pypi/v/pytest-services.svg
|
|
49
|
+
:target: https://pypi.python.org/pypi/pytest-services
|
|
50
|
+
.. image:: https://img.shields.io/pypi/pyversions/pytest-services.svg
|
|
51
|
+
:target: https://pypi.python.org/pypi/pytest-services
|
|
52
|
+
.. image:: https://img.shields.io/coveralls/pytest-dev/pytest-services/master.svg
|
|
53
|
+
:target: https://coveralls.io/r/pytest-dev/pytest-services
|
|
54
|
+
.. image:: https://travis-ci.org/pytest-dev/pytest-services.svg?branch=master
|
|
55
|
+
:target: https://travis-ci.org/pytest-dev/pytest-services
|
|
56
|
+
.. image:: https://readthedocs.org/projects/pytest-services/badge/?version=latest
|
|
57
|
+
:target: https://readthedocs.org/projects/pytest-services/?badge=latest
|
|
58
|
+
:alt: Documentation Status
|
|
59
|
+
|
|
60
|
+
Install pytest-services
|
|
61
|
+
-----------------------
|
|
62
|
+
|
|
63
|
+
::
|
|
64
|
+
|
|
65
|
+
pip install pytest-services
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
.. _pytest: http://pytest.org
|
|
69
|
+
.. _pytest-xdist: https://pypi.python.org/pypi/pytest-xdist
|
|
70
|
+
.. _pytest-splinter: https://pypi.python.org/pypi/pytest-splinter
|
|
71
|
+
.. _pytest-bdd: https://pypi.python.org/pypi/pytest-bdd
|
|
72
|
+
.. _pytest-django: https://pypi.python.org/pypi/pytest-django
|
|
73
|
+
.. _memcached: http://memcached.org
|
|
74
|
+
.. _xvfb: http://en.wikipedia.org/wiki/Xvfb
|
|
75
|
+
.. _mysql-server: http://dev.mysql.com/
|
|
76
|
+
|
|
77
|
+
Features
|
|
78
|
+
--------
|
|
79
|
+
|
|
80
|
+
The plugin provides a set of fixtures and utility functions to start service processes for your tests with
|
|
81
|
+
pytest_
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
Fixtures
|
|
85
|
+
--------
|
|
86
|
+
|
|
87
|
+
* run_services
|
|
88
|
+
Determines whether services should be run or not. False by default if not in distributed environment
|
|
89
|
+
(without pytest-xdist_). Can be manually set to True by overriding this fixture in your test config or
|
|
90
|
+
just by using `--run-services` command line argument (see below).
|
|
91
|
+
|
|
92
|
+
Infrastructure fixtures
|
|
93
|
+
***********************
|
|
94
|
+
|
|
95
|
+
* worker_id
|
|
96
|
+
Id of the worker if tests are run using pytest-xdist_. It is set to `local` if tests are not run using
|
|
97
|
+
pytest-xdist_ (with `--dist` command line option set to `load`).
|
|
98
|
+
Has a deprecated alias ``slave_id`` which will be removed in a future version.
|
|
99
|
+
* session_id
|
|
100
|
+
Test session id. Globally unique, and of course also guaranteed to be different for potentially multiple test
|
|
101
|
+
sessions running on same test node via pytest-xdist_.
|
|
102
|
+
* watcher_getter
|
|
103
|
+
Function to instantiate test service watcher (popen object). Includes automatic finalization (exiting) of the
|
|
104
|
+
service process, and testing the service before returning the watcher from the function.
|
|
105
|
+
Example of usage for memcached service:
|
|
106
|
+
|
|
107
|
+
.. code-block:: python
|
|
108
|
+
|
|
109
|
+
@pytest.fixture(scope='session')
|
|
110
|
+
def memcached(request, run_services, memcached_socket, watcher_getter):
|
|
111
|
+
"""The memcached instance which is ready to be used by the tests."""
|
|
112
|
+
if run_services:
|
|
113
|
+
return watcher_getter(
|
|
114
|
+
name='memcached',
|
|
115
|
+
arguments=['-s', memcached_socket],
|
|
116
|
+
checker=lambda: os.path.exists(memcached_socket),
|
|
117
|
+
# Needed for the correct execution order of finalizers
|
|
118
|
+
request=request,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
* services_log
|
|
122
|
+
Logger used for debug logging when managing test services.
|
|
123
|
+
* root_dir
|
|
124
|
+
Parent directory for test service artifacts (disk based). Set to `/tmp` by default.
|
|
125
|
+
* base_dir
|
|
126
|
+
Base directory for test service artifacts (disk based), unique subdirectory of `root_dir`.
|
|
127
|
+
Automatically removed recursively at the end of the test session.
|
|
128
|
+
* temp_dir
|
|
129
|
+
`Temporary` directory (disk based), subfolder of the `base_dir`.
|
|
130
|
+
Used for strictly temporary artifacts (for example - folder where files are uploaded from the user input).
|
|
131
|
+
* memory_root_dir
|
|
132
|
+
Parent directory for test service artifacts (memory based). Main idea of having memory base directory is to
|
|
133
|
+
store performance-critical files there. For example - mysql service will use it to store database file, it speeds up
|
|
134
|
+
mysql server a lot, especially database management operations.
|
|
135
|
+
Set to `/var/shm` by default, with a fallback to 'root_dir`. Note that if apparmor is running on your system, most
|
|
136
|
+
likely it will prevent your test service to use it (for example - mysql has it's apparmor profile). You you'll need
|
|
137
|
+
to disable such profile in apparmor configuration.
|
|
138
|
+
Example of disabling apparmor for mysqld:
|
|
139
|
+
|
|
140
|
+
.. code-block:: sh
|
|
141
|
+
|
|
142
|
+
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
|
|
143
|
+
sudo /etc/init.d/apparmor restart
|
|
144
|
+
|
|
145
|
+
* memory_base_dir
|
|
146
|
+
Base directory for test service artifacts (memory based), unique subdirectory of `memory_root_dir`.
|
|
147
|
+
Automatically removed recursively at the end of the test session.
|
|
148
|
+
* memory_temp_dir
|
|
149
|
+
`Temporary` directory (memory based), subfolder of the `base_dir`.
|
|
150
|
+
* lock_dir
|
|
151
|
+
Lock files directory for storing locks created for resource assignment (ports, display, etc). Subfolder of
|
|
152
|
+
`memory_root_dir`.
|
|
153
|
+
* run_dir
|
|
154
|
+
Process id and socket files directory (like system-wide `/var/run` but local for test session). Subfolder of
|
|
155
|
+
`memory_root_dir`.
|
|
156
|
+
* port_getter
|
|
157
|
+
Function to get unallocated port.
|
|
158
|
+
Automatically ensures locking and un-locking of it on application level via flock.
|
|
159
|
+
* display_getter
|
|
160
|
+
Function to get unallocated display.
|
|
161
|
+
Automatically ensures locking and un-locking of it on application level via flock.
|
|
162
|
+
* lock_resource_timeout
|
|
163
|
+
Used in function lock_resource.
|
|
164
|
+
A maximum of total sleep between attempts to lock resource.
|
|
165
|
+
|
|
166
|
+
Service fixtures
|
|
167
|
+
****************
|
|
168
|
+
|
|
169
|
+
* memcached
|
|
170
|
+
Start memcached_ instance.
|
|
171
|
+
Requires `pylibmc` installed or `memcache` indicated as an extra (`pip install 'pytest-services[memcached]'`).
|
|
172
|
+
* memcached_socket
|
|
173
|
+
Memcached unix socket file name to be used for connection.
|
|
174
|
+
* memcached_connection
|
|
175
|
+
Memcached connection string.
|
|
176
|
+
* do_memcached_clean
|
|
177
|
+
Determine if memcached should be cleared before every test run. Equals to `run_services` fixture by default.
|
|
178
|
+
Requires `pylibmc` installed or `memcache` indicated as an extra (`pip install 'pytest-services[memcached]'`).
|
|
179
|
+
* memcached_client
|
|
180
|
+
A pylibmc.Client instance bound to the service.
|
|
181
|
+
Requires `pylibmc` installed or `memcache` indicated as an extra (`pip install 'pytest-services[memcached]'`).
|
|
182
|
+
* mysql
|
|
183
|
+
Start mysql-server_ instance.
|
|
184
|
+
* mysql_database_name
|
|
185
|
+
MySQL database name to be created after initialization of the mysql service `system` database.
|
|
186
|
+
* mysql_database_getter
|
|
187
|
+
Function with single parameter - database name. To create additional database(s) for tests.
|
|
188
|
+
Used in `mysql_database` fixture which is used by `mysql` one.
|
|
189
|
+
* mysql_connection
|
|
190
|
+
MySQL connection string.
|
|
191
|
+
* xvfb
|
|
192
|
+
Start xvfb_ instance.
|
|
193
|
+
* xvfb_display
|
|
194
|
+
Xvfb display to use for connection.
|
|
195
|
+
* xvfb_resolution
|
|
196
|
+
Xvfb display resolution to use. Tuple in form `(1366, 768, 8)`.
|
|
197
|
+
|
|
198
|
+
Utility functions
|
|
199
|
+
*****************
|
|
200
|
+
|
|
201
|
+
Django settings
|
|
202
|
+
^^^^^^^^^^^^^^^
|
|
203
|
+
|
|
204
|
+
In some cases, there's a need of switching django settings during test run, because several django projects are tested
|
|
205
|
+
whithin the single test suite.
|
|
206
|
+
`pytest_services.django_settings` simplifies switching of django settings to a single function call:
|
|
207
|
+
|
|
208
|
+
* setup_django_settings
|
|
209
|
+
Override the enviroment variable and call the _setup method of the settings object to reload them.
|
|
210
|
+
|
|
211
|
+
Example of usage:
|
|
212
|
+
|
|
213
|
+
conftest.py:
|
|
214
|
+
|
|
215
|
+
.. code-block:: python
|
|
216
|
+
|
|
217
|
+
from pytest_services import django_settings
|
|
218
|
+
|
|
219
|
+
django_settings.clean_django_settings()
|
|
220
|
+
django_settings.setup_django_settings('your.project.settings')
|
|
221
|
+
|
|
222
|
+
Note that the nice project pytest-django_ doesn't help with the situation, as it's single django project oriented, as
|
|
223
|
+
well as standard django testing technique. Single project approach works fine, as long as there are no fixtures to share
|
|
224
|
+
between them, but when there are fixtures to share, then you can get benefit of joining several django projects tests
|
|
225
|
+
into a single test run, because all session-scoped fixtures will be instantiated only once for all projects tests.
|
|
226
|
+
The benefit is only visible if you have big enough test suite and your fixtures are heavy enough.
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
Command-line options
|
|
230
|
+
--------------------
|
|
231
|
+
|
|
232
|
+
* `--run-services`
|
|
233
|
+
Force services to be run even if tests are executed in a non-distributed way (without pytest-xdist_).
|
|
234
|
+
* `--xvfb-display`
|
|
235
|
+
Skip xvfb service to run and use provided display. Useful when you need to run all services except the xvfb_
|
|
236
|
+
to debug your browser tests, if, for example you use pytest-splinter_ with or without pytest-bdd_.
|
|
237
|
+
|
|
238
|
+
Example
|
|
239
|
+
-------
|
|
240
|
+
|
|
241
|
+
test_your_test.py:
|
|
242
|
+
|
|
243
|
+
.. code-block:: python
|
|
244
|
+
|
|
245
|
+
import MySQLdb
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def test_some_mysql_stuff(mysql):
|
|
249
|
+
"""Test using mysql server."""
|
|
250
|
+
conn = MySQLdb.connect(user='root')
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
Contact
|
|
254
|
+
-------
|
|
255
|
+
|
|
256
|
+
If you have questions, bug reports, suggestions, etc. please create an issue on
|
|
257
|
+
the `GitHub project page <https://github.com/pytest-dev/pytest-services>`_.
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
License
|
|
261
|
+
-------
|
|
262
|
+
|
|
263
|
+
This software is licensed under the `MIT license <http://en.wikipedia.org/wiki/MIT_License>`_
|
|
264
|
+
|
|
265
|
+
See `License file <https://github.com/pytest-dev/pytest-services/blob/master/LICENSE.txt>`_
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
© 2014 Anatoly Bubenkov, Paylogic International and others.
|
|
269
|
+
|
|
270
|
+
Authors
|
|
271
|
+
=======
|
|
272
|
+
|
|
273
|
+
`Anatoly Bubenkov <bubenkoff@gmail.com>`_
|
|
274
|
+
idea and implementation
|
|
275
|
+
|
|
276
|
+
These people have contributed to `pytest-services`, in alphabetical order:
|
|
277
|
+
|
|
278
|
+
* `Alessio Bogon <youtux@github.com>`_
|
|
279
|
+
* `Dmitrijs Milajevs <dimazest@gmail.com>`_
|
|
280
|
+
* `Jason R. Coombs <jaraco@jaraco.com>`_
|
|
281
|
+
* `Joep van Dijken <joepvandijken@github.com>`_
|
|
282
|
+
* `Magnus Staberg <magnus@staberg.io>`_
|
|
283
|
+
* `Michael Shriver <mshriver@redhat.com>`_
|
|
284
|
+
* `Oleg Pidsadnyi <oleg.pidsadnyi@gmail.com>`_
|
|
285
|
+
* `Zac Hatfield-Dodds <zac@zhd.dev>`_
|
|
286
|
+
|
|
287
|
+
Changelog
|
|
288
|
+
=========
|
|
289
|
+
|
|
290
|
+
2.2.2
|
|
291
|
+
-----
|
|
292
|
+
|
|
293
|
+
- #47: Replace ``distutils.spawn.find_executable`` with ``shutil.which``. The package ``distutils`` is deprecated.
|
|
294
|
+
|
|
295
|
+
2.2.1
|
|
296
|
+
-----
|
|
297
|
+
|
|
298
|
+
- #42: Retry on ``zc.lockfile.LockError`` in ``file_lock``, use existing timeout kwarg (mshriver)
|
|
299
|
+
|
|
300
|
+
2.2.0
|
|
301
|
+
-----
|
|
302
|
+
|
|
303
|
+
- #38: Retry to lock resource if zc.lockfile.LockError is raised. Fix needed for pytest-xdist. (StabbarN)
|
|
304
|
+
|
|
305
|
+
2.1.0
|
|
306
|
+
-----
|
|
307
|
+
|
|
308
|
+
- #34: Deprecated ``slave_id`` fixture in favor of ``worker_id``,
|
|
309
|
+
for compatibility with ``pytest-xdist`` 2.
|
|
310
|
+
|
|
311
|
+
2.0.1
|
|
312
|
+
-----
|
|
313
|
+
|
|
314
|
+
- #20: Added workaround for issue with SysLogHandler.
|
|
315
|
+
|
|
316
|
+
2.0.0
|
|
317
|
+
-----
|
|
318
|
+
|
|
319
|
+
- #23: Rely on ``zc.lockfile`` for lockfile behavior.
|
|
320
|
+
- #28: Fixtures now supports later versions of mysql and no longer
|
|
321
|
+
support versions of mysql prior to ``mysql --initialize`` support.
|
|
322
|
+
- #29: Fix issues with later versions of mysql where ``mysql_defaults_file``
|
|
323
|
+
fixture would prevent startup of mysql.
|
|
324
|
+
- Fixed issue in test suite where mysql fixture was not tested.
|
|
325
|
+
- Removed ``pytest_services.locks.lock_file``.
|
|
326
|
+
|
|
327
|
+
1.3.1
|
|
328
|
+
-----
|
|
329
|
+
|
|
330
|
+
- Fix race condition causing when using port_getter/display_getter (youtux)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
1.3.0
|
|
334
|
+
-----
|
|
335
|
+
|
|
336
|
+
- Add `request` param to watcher_getter to have proper execution order
|
|
337
|
+
of finalizers (youtux).
|
|
338
|
+
|
|
339
|
+
1.2.1
|
|
340
|
+
-----
|
|
341
|
+
|
|
342
|
+
- Swap kill and terminate in watcher_getter finalization, allowing
|
|
343
|
+
for a more polite SIGTERM for terminating child procs on Unix. See
|
|
344
|
+
#15 for details (jaraco)
|
|
345
|
+
|
|
346
|
+
1.2.0
|
|
347
|
+
-----
|
|
348
|
+
|
|
349
|
+
- Make pylibmc an optional dependency, available as an extra (jaraco)
|
|
350
|
+
|
|
351
|
+
1.1.15
|
|
352
|
+
------
|
|
353
|
+
|
|
354
|
+
- Fixed hang with updated netcat-openbsd>=1.130.3 (joepvandijken)
|
|
355
|
+
|
|
356
|
+
1.1.14
|
|
357
|
+
------
|
|
358
|
+
|
|
359
|
+
- Use a different strategy to determine whether xvfb supports (youtux )
|
|
360
|
+
|
|
361
|
+
1.1.12
|
|
362
|
+
------
|
|
363
|
+
|
|
364
|
+
- use realpath for mysql base dir (bubenkoff)
|
|
365
|
+
|
|
366
|
+
1.1.11
|
|
367
|
+
------
|
|
368
|
+
|
|
369
|
+
- exclude locked displays for xvfb (bubenkoff)
|
|
370
|
+
|
|
371
|
+
1.1.7
|
|
372
|
+
-----
|
|
373
|
+
|
|
374
|
+
- django settings fix (olegpidsadnyi)
|
|
375
|
+
|
|
376
|
+
1.1.3
|
|
377
|
+
-----
|
|
378
|
+
|
|
379
|
+
- django 1.8 support (bubenkoff)
|
|
380
|
+
|
|
381
|
+
1.1.2
|
|
382
|
+
-----
|
|
383
|
+
|
|
384
|
+
- old django support fix (olegpidsadnyi)
|
|
385
|
+
|
|
386
|
+
1.1.0
|
|
387
|
+
-----
|
|
388
|
+
|
|
389
|
+
- django 1.7+ support (bubenkoff)
|
|
390
|
+
|
|
391
|
+
1.0.10
|
|
392
|
+
------
|
|
393
|
+
|
|
394
|
+
- removed auto artifacts cleanup (bubenkoff)
|
|
395
|
+
|
|
396
|
+
1.0.8
|
|
397
|
+
-----
|
|
398
|
+
|
|
399
|
+
- fixed popen arguments (bubenkoff)
|
|
400
|
+
|
|
401
|
+
1.0.2
|
|
402
|
+
-----
|
|
403
|
+
|
|
404
|
+
- added port and display getters (bubenkoff)
|
|
405
|
+
|
|
406
|
+
1.0.1
|
|
407
|
+
-----
|
|
408
|
+
|
|
409
|
+
- Improved documentation (bubenkoff)
|
|
410
|
+
|
|
411
|
+
1.0.0
|
|
412
|
+
-----
|
|
413
|
+
|
|
414
|
+
- Initial public release
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Here are the steps on how to make a new release.
|
|
2
|
+
|
|
3
|
+
1. Create a ``release-VERSION`` branch from ``upstream/main``.
|
|
4
|
+
2. Update ``CHANGELOG.rst``.
|
|
5
|
+
3. Push the branch to ``upstream``.
|
|
6
|
+
4. Once all tests pass, start the ``deploy`` workflow manually or via:
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
gh workflow run deploy.yml --repo pytest-dev/pytest-services --ref release-VERSION -f version=VERSION
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
5. Merge the PR.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""pytest-services package."""
|
|
2
|
-
__version__ = '2.2.
|
|
2
|
+
__version__ = '2.2.1'
|
|
@@ -7,7 +7,7 @@ import socket
|
|
|
7
7
|
import shlex
|
|
8
8
|
import subprocess32
|
|
9
9
|
|
|
10
|
-
from
|
|
10
|
+
from shutil import which
|
|
11
11
|
import pytest
|
|
12
12
|
|
|
13
13
|
from tests.fixtures.services.util import (
|
|
@@ -70,7 +70,7 @@ def xvfb_watcher(
|
|
|
70
70
|
with file_lock(
|
|
71
71
|
os.path.join(lock_dir, 'xvfb_{0}.lock'.format(display)),
|
|
72
72
|
operation=fcntl.LOCK_EX | fcntl.LOCK_NB):
|
|
73
|
-
xvfb =
|
|
73
|
+
xvfb = which('Xvfb')
|
|
74
74
|
assert xvfb, 'You have to have Xvfb installed'
|
|
75
75
|
cmd = (
|
|
76
76
|
'{xvfb} '
|
|
@@ -24,10 +24,21 @@ def file_lock(filename, remove=True, timeout=20):
|
|
|
24
24
|
"""A lock that is shared across processes.
|
|
25
25
|
|
|
26
26
|
:param filename: the name of the file that will be locked.
|
|
27
|
-
|
|
27
|
+
:param remove: whether or not to remove the file on context close
|
|
28
|
+
:param timeout: Amount of time to retry the file lock if a :class:`zc.lockfile.LockError` is hit
|
|
28
29
|
"""
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
total_seconds_slept = 0
|
|
31
|
+
while True:
|
|
32
|
+
try:
|
|
33
|
+
with contextlib.closing(zc.lockfile.SimpleLockFile(filename)) as lockfile:
|
|
34
|
+
yield lockfile._fp
|
|
35
|
+
break
|
|
36
|
+
except zc.lockfile.LockError as err:
|
|
37
|
+
if total_seconds_slept >= timeout:
|
|
38
|
+
raise err
|
|
39
|
+
seconds_to_sleep = random() * 0.1 + 0.05
|
|
40
|
+
total_seconds_slept += seconds_to_sleep
|
|
41
|
+
time.sleep(seconds_to_sleep)
|
|
31
42
|
|
|
32
43
|
remove and try_remove(filename)
|
|
33
44
|
|