Commits

Zero Piraeus committed 783047b

Rename '@fixture()' as '@with_fixture()'.

Comments (0)

Files changed (7)

 :Contact: z@etiol.net
 
 **fix** is a simple library to assist with the creation of fixtures for test
-functions, methods etc. It provides one decorator, ``fixture``, which allows
-you to attach setup and teardown functions to the decorated callable, and
-access information defined in the fixture from within the test function.
+functions, methods etc. It provides one decorator, ``with_fixture``, which
+allows you to attach setup and teardown functions to the decorated callable,
+and access information defined in the fixture from within the test function.
 
 
 Example
 """Simple test fixtures."""
 
-from fix.decorators import fixture
-from fix._version import __version__
+from .fix import with_fixture
+from ._version import __version__
 
 __all__ = (
-    fixture,
+    with_fixture,
 )
-"""Decorators."""
+"""Simple test fixtures."""
 
 from functools import wraps
 
 
-def fixture(create_fixture, **kwargs):
+def with_fixture(create_fixture, **kwargs):
     """Decorate a callable with a fixture."""
     context = {}
-    fixt = create_fixture(context, **kwargs)
-    if isinstance(fixt, tuple):
-        setup, teardown = fixt
+    fixture = create_fixture(context, **kwargs)
+    if isinstance(fixture, tuple):
+        setup, teardown = fixture
     else:
-        setup = fixt
+        setup = fixture
         teardown = lambda: None
 
     def wrap(func):

tests/test_fix/__init__.py

-"""Tests for the `fix.decorators` module."""
+"""Tests for the `fix.fix` module."""

tests/test_fix/examples.py

-"""Examples for `tests.decorators`."""
+"""Examples for `tests.test_fix`."""

tests/test_fix/test.py

-"""General tests for the `fix.decorators` module."""
+"""General tests for the `fix.fix` module."""
 
 from types import ModuleType
 
-import fix.decorators
+import fix.fix
 
 
 def test_exists():
-    """`fix.decorators` module exists"""
-    assert isinstance(fix.decorators, ModuleType)
+    """`fix.fix` module exists"""
+    assert isinstance(fix.fix, ModuleType)

tests/test_fix/test_with_fixture.py

-"""Tests for the `fix.decorators.fixture` function."""
+"""Tests for the `fix.fix.with_fixture` function."""
 
 from types import FunctionType
 
-from fix import fixture
+from fix import with_fixture
 
 
 def test_exists():
-    """`fix.fixture` function exists"""
-    assert isinstance(fixture, FunctionType)
+    """`fix.with_fixture` function exists"""
+    assert isinstance(with_fixture, FunctionType)
 
 
 def test_call():
-    """`fix.fixture` function does something sensible"""
+    """`fix.with_fixture` function does something sensible"""
 
     def my_fixture(context):
         """Create a fixture that assigns "bar" to `context["foo"]`."""
             context["foo"] = "bar"
         return setup
 
-    @fixture(my_fixture)
+    @with_fixture(my_fixture)
     def case(context):
         """Return `context["foo"]`."""
         return context["foo"]