Skip to content

Commit 894f39b

Browse files
committed
Docs: Replace Poetry with Hatch
1 parent c807e9f commit 894f39b

File tree

6 files changed

+36
-12
lines changed

6 files changed

+36
-12
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Release Notes
22
-------------
33

4+
**2.1.0 (2023-05-27)**
5+
6+
* Add support for ``pytest-metadata`` 3.x
7+
8+
* Switch to Hatch
9+
410
**2.0.0 (2022-03-27)**
511

612
* Drop python 2.7 and 3.6 support

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ You can specify the base URL on the command line:
6363

6464
.. code-block:: bash
6565
66-
$ py.test --base-url http://www.example.com
66+
$ pytest --base-url http://www.example.com
6767
6868
Using a Configuration File
6969
^^^^^^^^^^^^^^^^^^^^^^^^^^

development.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
Development
22
===========
33

4-
To contribute to `pytest-base-url` you can use `Poetry <https://python-poetry.org/>`_ to manage
4+
To contribute to `pytest-base-url` you can use `Hatch <https://hatch.pypa.io/latest/>`_ to manage
55
a python virtual environment and `pre-commit <https://pre-commit.com/>`_ to help you with
66
styling and formatting.
77

88
To setup the virtual environment and pre-commit, run:
99

1010
.. code-block:: bash
1111
12-
$ poetry install
13-
$ poetry run pre-commit install
12+
$ hatch -e test run pre-commit install
1413
15-
If you're not using ``Poetry``, to install ``pre-commit``, run:
14+
If you're not using ``Hatch``, to install ``pre-commit``, run:
1615

1716
.. code-block:: bash
1817
@@ -30,14 +29,14 @@ Running Tests
3029
-------------
3130

3231
You will need `Tox <https://tox.wiki/en/latest/>`_ installed to run the tests
33-
against the supported Python versions. If you're using ``Poetry`` it will be
32+
against the supported Python versions. If you're using ``Hatch`` it will be
3433
installed for you.
3534

36-
With ``Poetry``, run:
35+
With ``Hatch``, run:
3736

3837
.. code-block:: bash
3938
40-
$ poetry run tox
39+
$ hatch -e test run tox
4140
4241
Otherwise, to install and run, do:
4342

@@ -57,6 +56,6 @@ Follow these steps to release a new version of the project:
5756
#. Commit and push the new branch and then create a new pull request
5857
#. Wait for tests and reviews and then merge the branch
5958
#. Once merged, update your local master again (``git pull --rebase upstream master``)
60-
#. Tag the release with the new release version (``git tag v<new tag>``)
59+
#. Tag the release with the new release version (``git tag <new tag>``)
6160
#. Push the tag (``git push upstream --tags``)
6261
#. Done.

src/pytest_base_url/plugin.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
import os
6-
76
import pytest
87

98

@@ -39,8 +38,14 @@ def pytest_configure(config):
3938
base_url = config.getoption("base_url") or config.getini("base_url")
4039
if base_url is not None:
4140
config.option.base_url = base_url
42-
if hasattr(config, "_metadata"):
43-
config._metadata["Base URL"] = base_url
41+
metadata = config.pluginmanager.getplugin("metadata")
42+
if metadata:
43+
try:
44+
from pytest_metadata.plugin import metadata_key
45+
46+
config.stash[metadata_key]["Base URL"] = base_url
47+
except ImportError: # pytest-metadata < 3.x
48+
config._metadata["Base URL"] = base_url
4449

4550

4651
def pytest_report_header(config, startdir):

tests/test_base_url.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,16 @@ def test_config(request, base_url):
8282
reprec = testdir.inline_run()
8383
passed, skipped, failed = reprec.listoutcomes()
8484
assert len(passed) == 1
85+
86+
87+
def test_metadata(testdir, monkeypatch):
88+
testdir.makepyfile(
89+
"""
90+
def test_config(metadata):
91+
assert metadata["Base URL"] == 'yeehaw'
92+
"""
93+
)
94+
monkeypatch.setenv("PYTEST_BASE_URL", "yeehaw")
95+
reprec = testdir.inline_run()
96+
passed, skipped, failed = reprec.listoutcomes()
97+
assert len(passed) == 1

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ setenv =
77
PYTHONDONTWRITEBYTECODE=1
88
deps =
99
pytest-localserver
10+
pytest-metadata
1011
commands = pytest -s -ra --color=yes {posargs}
1112

1213
[testenv:linting]

0 commit comments

Comments
 (0)