Skip to content

Commit

Permalink
Merge pull request #37 from BeyondEvil/beyondevil/fix-docs
Browse files Browse the repository at this point in the history
Docs: Replace Poetry with Hatch
  • Loading branch information
BeyondEvil authored May 27, 2023
2 parents c807e9f + 894f39b commit bf264b8
Showing 6 changed files with 36 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release Notes
-------------

**2.1.0 (2023-05-27)**

* Add support for ``pytest-metadata`` 3.x

* Switch to Hatch

**2.0.0 (2022-03-27)**

* Drop python 2.7 and 3.6 support
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ You can specify the base URL on the command line:

.. code-block:: bash
$ py.test --base-url http://www.example.com
$ pytest --base-url http://www.example.com
Using a Configuration File
^^^^^^^^^^^^^^^^^^^^^^^^^^
15 changes: 7 additions & 8 deletions development.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
Development
===========

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

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

.. code-block:: bash
$ poetry install
$ poetry run pre-commit install
$ hatch -e test run pre-commit install
If you're not using ``Poetry``, to install ``pre-commit``, run:
If you're not using ``Hatch``, to install ``pre-commit``, run:

.. code-block:: bash
@@ -30,14 +29,14 @@ Running Tests
-------------

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

With ``Poetry``, run:
With ``Hatch``, run:

.. code-block:: bash
$ poetry run tox
$ hatch -e test run tox
Otherwise, to install and run, do:

@@ -57,6 +56,6 @@ Follow these steps to release a new version of the project:
#. Commit and push the new branch and then create a new pull request
#. Wait for tests and reviews and then merge the branch
#. Once merged, update your local master again (``git pull --rebase upstream master``)
#. Tag the release with the new release version (``git tag v<new tag>``)
#. Tag the release with the new release version (``git tag <new tag>``)
#. Push the tag (``git push upstream --tags``)
#. Done.
11 changes: 8 additions & 3 deletions src/pytest_base_url/plugin.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import os

import pytest


@@ -39,8 +38,14 @@ def pytest_configure(config):
base_url = config.getoption("base_url") or config.getini("base_url")
if base_url is not None:
config.option.base_url = base_url
if hasattr(config, "_metadata"):
config._metadata["Base URL"] = base_url
metadata = config.pluginmanager.getplugin("metadata")
if metadata:
try:
from pytest_metadata.plugin import metadata_key

config.stash[metadata_key]["Base URL"] = base_url
except ImportError: # pytest-metadata < 3.x
config._metadata["Base URL"] = base_url


def pytest_report_header(config, startdir):
13 changes: 13 additions & 0 deletions tests/test_base_url.py
Original file line number Diff line number Diff line change
@@ -82,3 +82,16 @@ def test_config(request, base_url):
reprec = testdir.inline_run()
passed, skipped, failed = reprec.listoutcomes()
assert len(passed) == 1


def test_metadata(testdir, monkeypatch):
testdir.makepyfile(
"""
def test_config(metadata):
assert metadata["Base URL"] == 'yeehaw'
"""
)
monkeypatch.setenv("PYTEST_BASE_URL", "yeehaw")
reprec = testdir.inline_run()
passed, skipped, failed = reprec.listoutcomes()
assert len(passed) == 1
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ setenv =
PYTHONDONTWRITEBYTECODE=1
deps =
pytest-localserver
pytest-metadata
commands = pytest -s -ra --color=yes {posargs}

[testenv:linting]

0 comments on commit bf264b8

Please sign in to comment.