Commits

Zero Piraeus committed d61143b

Reorganise files.

  • Participants
  • Parent commits 8849fc5

Comments (0)

Files changed (10)

fix/decorators.py

-"""Decorators."""
-
-from functools import wraps
-
-
-def fixture(create_fixture, **kwargs):
-    """Decorate a callable with a fixture."""
-    context = {}
-    fixt = create_fixture(context, **kwargs)
-    if isinstance(fixt, tuple):
-        setup, teardown = fixt
-    else:
-        setup = fixt
-        teardown = lambda: None
-
-    def wrap(func):
-        """Wrap the callable."""
-        @wraps(func)
-        def call():
-            """Call `setup` and `teardown` before and after `func`."""
-            setup()
-            result = func(context)
-            teardown()
-            return result
-        return call
-
-    return wrap
+"""Decorators."""
+
+from functools import wraps
+
+
+def fixture(create_fixture, **kwargs):
+    """Decorate a callable with a fixture."""
+    context = {}
+    fixt = create_fixture(context, **kwargs)
+    if isinstance(fixt, tuple):
+        setup, teardown = fixt
+    else:
+        setup = fixt
+        teardown = lambda: None
+
+    def wrap(func):
+        """Wrap the callable."""
+        @wraps(func)
+        def call():
+            """Call `setup` and `teardown` before and after `func`."""
+            setup()
+            result = func(context)
+            teardown()
+            return result
+        return call
+
+    return wrap

tests/decorators/__init__.py

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

tests/decorators/examples.py

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

tests/decorators/test.py

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

tests/decorators/test_fixture.py

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

tests/test_fix/__init__.py

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

tests/test_fix/examples.py

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

tests/test_fix/test.py

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

tests/test_fix/test_with_fixture.py

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