<commit_before>from nose.tools import eq_

from ..context import Context
from ..dependent import Dependent


def test_context():
    # No context
    context = Context()
    foo = Dependent("foo", lambda: "foo")
    bar = Dependent("bar", lambda: "bar")
    foobar = Dependent("foobar", lambda foo, bar: foo + bar,
                       depends_on=[foo, bar])
    eq_(context.solve(foobar), "foobar")
    eq_(list(context.solve([foo, bar, foobar])), ["foo", "bar", "foobar"])

    # Cache context
    context = Context(cache={bar: "baz"})
    eq_(context.solve(foobar), "foobaz")

    # Context context
    mybar = Dependent("bar", lambda: "baz")

    context = Context(context={mybar})
    eq_(context.solve(foobar), "foobaz")

    context = Context(context={mybar: mybar})
    eq_(context.solve(foobar), "foobaz")

    context = Context(context={bar: mybar})
    eq_(context.solve(foobar), "foobaz")

    context = Context(context={bar: lambda: "baz"})
    eq_(context.solve(foobar), "foobaz")<commit_msg>Adds a call to update() in context tests<commit_after>from nose.tools import eq_

from ..context import Context
from ..dependent import Dependent


def test_context():
    # No context
    context = Context()
    foo = Dependent("foo", lambda: "foo")
    bar = Dependent("bar", lambda: "bar")
    foobar = Dependent("foobar", lambda foo, bar: foo + bar,
                       depends_on=[foo, bar])
    eq_(context.solve(foobar), "foobar")
    eq_(list(context.solve([foo, bar, foobar])), ["foo", "bar", "foobar"])

    # Cache context
    context = Context(cache={bar: "baz"})
    eq_(context.solve(foobar), "foobaz")

    # Context context
    mybar = Dependent("bar", lambda: "baz")

    context = Context(context={mybar})
    eq_(context.solve(foobar), "foobaz")

    context = Context(context={mybar: mybar})
    eq_(context.solve(foobar), "foobaz")

    context = Context(context={bar: mybar})
    eq_(context.solve(foobar), "foobaz")

    context = Context(context={bar: lambda: "baz"})
    eq_(context.solve(foobar), "foobaz")
    context.update(context={bar: lambda: "buzz"})
    eq_(context.solve(foobar), "foobuzz")
{'fraction_non_alphanumeric': 0.16580796252927402, 'fraction_numerical': 0.0, 'mean_word_length': 3.757238307349666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6637750', 'n_tokens_mistral': 745, 'n_tokens_neox': 697, 'n_words': 163}