2016-04-06 14:20:30 +01:00
|
|
|
"""A sample pytest module."""
|
|
|
|
|
|
|
|
# For pathname munging
|
|
|
|
import os
|
|
|
|
|
|
|
|
# The module that build_tests comes from.
|
|
|
|
from gabbi import driver
|
|
|
|
|
|
|
|
# We need access to the WSGI application that hosts our service
|
|
|
|
from myapp import wsgiapp
|
|
|
|
|
|
|
|
# We're using fixtures in the YAML files, we need to know where to
|
|
|
|
# load them from.
|
|
|
|
from myapp.test import fixtures
|
|
|
|
|
|
|
|
# By convention the YAML files are put in a directory named
|
|
|
|
# "gabbits" that is in the same directory as the Python test file.
|
|
|
|
TESTS_DIR = 'gabbits'
|
|
|
|
|
|
|
|
|
|
|
|
def test_gabbits():
|
|
|
|
test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)
|
2016-06-02 09:15:57 +01:00
|
|
|
# Pass "require_ssl=True" as an argument to force all tests
|
|
|
|
# to use SSL in requests.
|
2016-04-06 14:20:30 +01:00
|
|
|
test_generator = driver.py_test_generator(
|
|
|
|
test_dir, intercept=wsgiapp.app,
|
|
|
|
fixture_module=fixtures)
|
|
|
|
|
|
|
|
for test in test_generator:
|
|
|
|
yield test
|