How to use the forbiddenfruit.cursed function in forbiddenfruit

To help you get started, we’ve selected a few forbiddenfruit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github clarete / forbiddenfruit / tests / unit / test_forbidden_fruit.py View on Github external
def test_cursed_context_manager():
    "The `cursed` context manager should curse an existing symbols in a scope"

    # Given that I have an instance of a python class
    obj = {'a': 1, 'b': 2}

    # When I curse an instance method
    with cursed(dict, "open_box", lambda self: 'surprise'):
        # Then I see that my object was cursed properly
        assert obj.open_box() == 'surprise'

    # And it was reversed
    assert "open_box" not in dir(obj)
    assert "open_box" not in dir(dict)
github clarete / forbiddenfruit / tests / unit / test_forbidden_fruit.py View on Github external
    @cursed(dict, "open_box", lambda self: 'surprise')
    def function():
        # Then I see that my object was cursed properly
        assert obj.open_box() == 'surprise'