import pytest

import parsenvy


@pytest.fixture(scope="function")
def func():
    def inner_func(arg, default=None):
        return arg

    return inner_func


def test_default_if_none_arg(func, monkeypatch):
    """Desired env var is set."""
    monkeypatch.setenv("foo", "bar")

    decorated_func = parsenvy.default_if_none(func)
    value = decorated_func("foo")
    assert value == "bar"


def test_default_if_none_default(func, monkeypatch):
    """Desired env var isn't set, default is supplied."""
    monkeypatch.delenv("foo", raising=False)

    decorated_func = parsenvy.default_if_none(func)
    value = decorated_func("foo", "bar")
    assert value == "bar"


def test_default_if_none_neither(func, monkeypatch):
    """Desired env var isn't set, default isn't supplied."""
    monkeypatch.delenv("foo", raising=False)

    decorated_func = parsenvy.default_if_none(func)
    value = decorated_func("foo")
    assert value is None

@@ -324,39 +324,38 @@
 _none(func)%0A    
-value =
+assert
  decorated_func(
@@ -360,33 +360,16 @@
 c(%22foo%22)
-%0A    assert value
  == %22bar
@@ -577,39 +577,38 @@
 _none(func)%0A    
-value =
+assert
  decorated_func(
@@ -620,33 +620,16 @@
 , %22bar%22)
-%0A    assert value
  == %22bar
@@ -852,15 +852,14 @@
     
-value =
+assert
  dec
@@ -880,25 +880,8 @@
 oo%22)
-%0A    assert value
  is 

Clean up decorator tests