Commits

Zero Piraeus  committed 9917a84

Add 'test_setup_teardown()'.

  • Participants
  • Parent commits 64ee793

Comments (0)

Files changed (1)

File tests/test_fix/test_with_fixture.py

         return context["foo"]
 
     assert case() == "bar"  # pylint: disable=E1120
+
+
+def test_setup_teardown():
+    """`@with_fixture()` handles fixtures which return a tuple of functions"""
+    pseudoglobal = {}
+
+    def fixture(context):
+        """Create a fixture that assigns "bar" to `context["foo"]`."""
+
+        def setup():
+            """Assign "bar" to `context["foo"]`."""
+            context["foo"] = "squee"
+
+        def teardown():
+            """Delete `context["foo"]`."""
+            del context["foo"]
+            pseudoglobal["teardown_context"] = context
+
+        return setup, teardown
+
+    @with_fixture(fixture)
+    def case(context):
+        """Return `context["foo"]`."""
+        return context["foo"]
+
+    assert case() == "squee"  # pylint: disable=E1120
+    assert pseudoglobal["teardown_context"] == {}