Skip to content

Commit 0c418ba

Browse files
committed
doc: major reorg + user guide
1 parent 68892f8 commit 0c418ba

4 files changed

Lines changed: 32 additions & 47 deletions

File tree

doc/changes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. release-notes:: Release Notes
2+

doc/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
# Add any Sphinx extension module names here, as strings. They can be
3232
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3333
# ones.
34-
extensions = ['sphinx.ext.autodoc']
34+
extensions = [
35+
'sphinx.ext.autodoc',
36+
'reno.sphinxext',
37+
]
3538

3639
# Add any paths that contain templates here, relative to this directory.
3740
templates_path = ['_templates']

doc/guide.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
User's Guide
3+
============
4+
5+
Starting and stopping the server
6+
--------------------------------
7+
The server can be started by instatiating it and then calling the
8+
:py:meth:`pytest_httpserver.HTTPServer.start` method. This will start the server in a separate
9+
thread, so you will need to make sure that the :py:meth:`pytest_httpserver.HTTPServer.stop` method
10+
is called before your code exits.
11+
12+
A free TCP port needs to be specified when instantiating the server, where no other daemon is listening.
13+
14+
If you are using the pytest plugin it is done automatically by the plugin. Possibility to change
15+
the TCP port in this case is TBD.
16+

doc/index.rst

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
.. pytest_httpserver documentation master file, created by
2-
sphinx-quickstart on Sat Aug 11 08:07:37 2018.
3-
You can adapt this file completely to your liking, but it should at least
4-
contain the root `toctree` directive.
51

2+
pytest-httpserver
3+
=================
64

7-
User's Guide
8-
------------
95
pytest-httpserver is a python package which allows you to start a real HTTP server
106
for your tests. The server can be configured programmatically to how to respond to
117
requests.
@@ -22,8 +18,9 @@ This library can be used with pytest in the most convenient way but if you prefe
2218
other test frameworks, you can still use it with the context API or by writing a wrapper
2319
for it.
2420

25-
Example with pytest
26-
-------------------
21+
22+
Example
23+
-------
2724

2825
.. code:: python
2926
@@ -34,44 +31,11 @@ Example with pytest
3431
assert requests.get(httpserver.url_for("/foobar")).json() == {'foo': 'bar'}
3532
3633
37-
Example without pytest
38-
----------------------
39-
40-
.. code:: python
41-
42-
import requests
43-
import unittest
44-
from pytest_httpserver import HTTPServer
45-
46-
class TestJSONClient(unittest.TestCase):
47-
def setUp(self):
48-
self.httpserver = HTTPServer()
49-
self.httpserver.start()
50-
51-
def test_json_client(self):
52-
self.httpserver.expect_request("/foobar").respond_with_json({"foo": "bar"})
53-
self.assertEqual(requests.get(self.httpserver.url_for("/foobar")).json(), {'foo': 'bar'})
54-
55-
def tearDown(self):
56-
self.httpserver.stop()
57-
58-
59-
API Reference
60-
-------------
61-
62-
If you are looking for information on a specific function, class or
63-
method, this part of the documentation is for you.
34+
For further details, please read the :doc:`guide` or the :doc:`api`.
6435

6536
.. toctree::
66-
:maxdepth: 2
67-
68-
api
69-
70-
71-
72-
Indices and tables
73-
==================
37+
:maxdepth: 1
7438

75-
* :ref:`genindex`
76-
* :ref:`modindex`
77-
* :ref:`search`
39+
guide
40+
api
41+
changes

0 commit comments

Comments
 (0)