Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Tidying up namespaces (#220)
Browse files Browse the repository at this point in the history
* Tidying up public API, moving towards stabilisation

* Remove unused variables

* Expanding docs: add reference section

* Add significant docs

* Add further docs to reference section
  • Loading branch information
darrenburns authored May 20, 2021
1 parent d70c0ce commit 8f40f82
Show file tree
Hide file tree
Showing 36 changed files with 540 additions and 507 deletions.
151 changes: 0 additions & 151 deletions .all-contributorsrc

This file was deleted.

10 changes: 6 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))


# -- Project information -----------------------------------------------------
Expand All @@ -31,7 +31,9 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autosectionlabel',
"sphinx.ext.autodoc",
"sphinx.ext.autosectionlabel",
"sphinx.ext.napoleon",
]

autosectionlabel_prefix_document = True
Expand Down
7 changes: 4 additions & 3 deletions docs/source/guide/pyproject.toml.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _pyproject:

Configuring Ward in ``pyproject.toml``
========================================
Configuration
=============

How does Ward use ``pyproject.toml``?
-------------------------------------
Expand Down Expand Up @@ -39,4 +39,5 @@ all of your Ward configuration should appear there:
order = "standard" # or 'random'
output-mode = "test-per-line" # or 'dots-global', 'dot-module'
fail-limit = 20 # stop the run if 20 fails occur
search = "my_function" # search in test body or description
search = "my_function" # search in test body or description
progress-style = ["bar"] # display a progress bar during the run
13 changes: 11 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Features
* Support for :ref:`testing async code<async_tests>`
* :ref:`Parameterised testing <parameterisation>` allows you to run a single test on multiple inputs
* Configurable with :ref:`pyproject.toml<pyproject>`, but works out-of-the-box with sensible defaults
* Fast -- Ward's suite of ~250 tests completes in <0.3 seconds on my machine
* Speedy -- Ward's suite of ~300 tests completes in ~0.4 seconds on my machine

.. image:: ./_static/intro_screenshot.png
:align: center
Expand Down Expand Up @@ -57,4 +57,13 @@ To run the test, simply run ``ward`` in your terminal, and Ward will let you kno
:caption: Tutorials

tutorials/first_tests.rst
tutorials/testing_flask.rst
tutorials/testing_flask.rst

.. toctree::
:maxdepth: 2
:caption: Reference
:glob:

reference/testing.rst
reference/fixtures.rst

18 changes: 18 additions & 0 deletions docs/source/reference/fixtures.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
``ward.fixtures``
===================

Standard API
-------------

.. automodule:: ward.fixtures
:members: fixture, using

Plugin API (in development)
----------------------------
This section contains items from this module that are intended for use by plugin authors or those contributing to Ward itself.
If you're just using Ward to write your tests, this section isn't relevant.

.. automodule:: ward.fixtures
:noindex:
:members: Fixture

18 changes: 18 additions & 0 deletions docs/source/reference/testing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
``ward.testing``
===================

Standard API
-------------

.. automodule:: ward.testing
:members: test, skip, xfail

Plugin API (in development)
----------------------------
This section contains items from this module that are intended for use by plugin authors or those contributing to Ward itself.
If you're just using Ward to write your tests, this section isn't relevant.

.. automodule:: ward.testing
:noindex:
:members: Test, TestOutcome, TestResult

2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Sphinx = "^3.5.1"
sphinx-rtd-theme = "^0.5.1"

[tool.poetry.scripts]
ward = "ward.run:run"
ward = "ward._run:run"

[tool.coverage.report]
exclude_lines = [
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from click.testing import CliRunner

from ward import each, test
from ward.run import run
from ward._run import run


@test("Cannot use bar progress style with {output_style} output style")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from cucumber_tag_expressions import parse

from ward import fixture, raises, test
from ward.collect import (
from ward._collect import (
_get_module_path,
_handled_within,
_is_excluded_module,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import click

from ward import test, fixture, raises, each
from ward.config import read_config_toml, as_list, apply_multi_defaults
from ward._config import read_config_toml, as_list, apply_multi_defaults


def temp_conf(conf: str) -> tempfile._TemporaryFileWrapper:
Expand Down
16 changes: 8 additions & 8 deletions tests/test_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from unittest import mock
from unittest.mock import Mock

from ward import test, debug
from ward.debug import init_breakpointhooks, _breakpointhook, _get_debugger_hook, importlib
from ward import test, _debug
from ward._debug import init_breakpointhooks, _breakpointhook, _get_debugger_hook, importlib


@test("init_breakpointhooks always patches pdb.set_trace")
Expand All @@ -18,21 +18,21 @@ def _():

@test("init_breakpointhooks sets sys.breakpointhook when it's supported")
def _():
old_func = debug._breakpoint_supported
debug._breakpoint_supported = lambda: True
old_func = _debug._breakpoint_supported
_debug._breakpoint_supported = lambda: True
mock_sys = SimpleNamespace()
init_breakpointhooks(pdb_module=Mock(), sys_module=mock_sys)
debug._breakpoint_supported = old_func
_debug._breakpoint_supported = old_func
assert mock_sys.breakpointhook == _breakpointhook


@test("init_breakpointhooks doesnt set breakpointhook when it's unsupported")
def _():
old_func = debug._breakpoint_supported
debug._breakpoint_supported = lambda: False
old_func = _debug._breakpoint_supported
_debug._breakpoint_supported = lambda: False
mock_sys = SimpleNamespace()
init_breakpointhooks(pdb_module=Mock(), sys_module=mock_sys)
debug._breakpoint_supported = old_func
_debug._breakpoint_supported = old_func
assert not hasattr(mock_sys, "breakpointhook")


Expand Down
12 changes: 5 additions & 7 deletions tests/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
import sys

from tests.utilities import testable_test
from ward.fixtures import (
is_fixture,
fixture_parents_and_children,
)
from ward import fixture, test, Scope, raises, each
from ward.fixtures import Fixture, FixtureCache, using
from ward import fixture, test, raises, each
from ward.models import Scope
from ward.fixtures import Fixture, using
from ward._fixtures import FixtureCache, is_fixture, fixture_parents_and_children
from ward.testing import Test
from ward.errors import FixtureError
from ward._errors import FixtureError
from tests.utilities import dummy_fixture


Expand Down
6 changes: 3 additions & 3 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from tests.test_testing import TRUTHY_PREDICATES, FALSY_PREDICATES
from ward import test, each, Scope, raises
from ward.errors import FixtureError
from ward.models import SkipMarker, XfailMarker
from ward import test, each, raises
from ward._errors import FixtureError
from ward.models import SkipMarker, XfailMarker, Scope


@test("Scope.from_str('{string}') returns {scope}")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from tests.utilities import testable_test
from ward import test, fixture
from ward.rewrite import (
from ward._rewrite import (
rewrite_assertions_in_tests,
RewriteAssert,
get_assertion_msg,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_suite.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from unittest import mock

from ward import fixture
from ward.errors import ParameterisationError
from ward._errors import ParameterisationError
from ward.models import Scope, SkipMarker
from ward.suite import Suite
from ward._suite import Suite
from ward.testing import Test, skip, TestOutcome, TestResult, test, each
from tests.utilities import NUMBER_OF_TESTS, testable_test, example_test, module

Expand Down
Loading

0 comments on commit 8f40f82

Please sign in to comment.