Skip to content

Commit

Permalink
Note that current hooks are not stable
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelboulton committed Aug 26, 2019
1 parent 765b76a commit 6b25809
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
10 changes: 7 additions & 3 deletions docs/source/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,11 @@ tests.

These hooks are used by defining a function with the name of the hook in your
`conftest.py` that take the same arguments _with the same names_ - these hooks
will then be picked up at runtime and called appropriately
will then be picked up at runtime and called appropriately.

**NOTE**: These hooks should be considered a 'beta' feature, they are ready to
use but the names and arguments they take should be considered unstable and may
change in a future release (and more may also be added).

### Before every test run

Expand All @@ -1968,7 +1972,7 @@ Example usage:
```python
import logging
def pytest_tavern_before_every_test_run(test_dict, variables):
def pytest_tavern_beta_before_every_test_run(test_dict, variables):
logging.info("Starting test %s", test_dict["test_name"])
variables["extra_var"] = "abc123"
Expand All @@ -1990,7 +1994,7 @@ Args:
Example usage:

```python
def pytest_tavern_after_every_response(expected, response):
def pytest_tavern_beta_after_every_response(expected, response):
with open("logfile.txt", "a") as logfile:
logfile.write("Got response: {}".format(response.json()))
```
2 changes: 1 addition & 1 deletion example/hooks/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def setup_logging():
logging.basicConfig(level=logging.INFO)


def pytest_tavern_after_every_response(expected, response):
def pytest_tavern_beta_after_every_response(expected, response):
global name
logging.debug(expected)
logging.debug(response)
Expand Down
2 changes: 1 addition & 1 deletion tavern/_plugins/mqtt/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _await_response(self):

call_hook(
self.test_block_config,
"pytest_tavern_after_every_response",
"pytest_tavern_beta_after_every_response",
expected=self.expected,
response=msg,
)
Expand Down
2 changes: 1 addition & 1 deletion tavern/_plugins/rest/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def verify(self, response):

call_hook(
self.test_block_config,
"pytest_tavern_after_every_response",
"pytest_tavern_beta_after_every_response",
expected=self.expected,
response=response,
)
Expand Down
2 changes: 1 addition & 1 deletion tavern/testutils/pytesthook/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def runtest(self):

call_hook(
self.global_cfg,
"pytest_tavern_before_every_test_run",
"pytest_tavern_beta_before_every_test_run",
test_dict=self.spec,
variables=self.global_cfg["variables"],
)
Expand Down
4 changes: 2 additions & 2 deletions tavern/testutils/pytesthook/newhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
logger = logging.getLogger(__name__)


def pytest_tavern_before_every_test_run(test_dict, variables):
def pytest_tavern_beta_before_every_test_run(test_dict, variables):
"""Called:
- directly after fixtures are loaded for a test
Expand All @@ -21,7 +21,7 @@ def pytest_tavern_before_every_test_run(test_dict, variables):
"""


def pytest_tavern_after_every_response(expected, response):
def pytest_tavern_beta_after_every_response(expected, response):
"""Called after every _response_ - including MQTT/HTTP/etc
Note:
Expand Down

0 comments on commit 6b25809

Please sign in to comment.