def test_context_object_multiple_returns():
    with BiggerExample() as e2:
        eq(e2.s66, 66)
        eq(e2.one, 1)
        eq(e2.two, 2)
Beispiel #2
0
def test_thread_start_stop():
    t = Threadable()
    t.start()
    eq(threading.active_count(), 2)
    t.stop()
def test_context_object():
    with Example() as e:
        eq(e.s66, 66)
Beispiel #4
0
def test_thread_context_manager():
    with threadable():
        eq(threading.active_count(), 2)
Beispiel #5
0
def test_simultaneous_threads():
    num_threads = 4
    threads = [Threadable() for _ in range(num_threads)]
    [t.start() for t in threads]
    eq(threading.active_count(), num_threads + 1)
    [t.stop() for t in threads]
Beispiel #6
0
def test_andn():
    eq(False, andn(True, False, True))
    eq(True, andn(True, True, True))
    eq(False, andn(True, False))
    eq(False, andn(False, False))
    eq(True, andn(True, True))
    eq(True, andn(*[True for _ in range(1000)]))
    eq(True, andn(True))
    eq(True, andn())
Beispiel #7
0
def test_stringify_times():
    st = stringify_times
    # Dicts
    eq({}, st({}))
    eq({"a": 1}, st({"a": 1}))
    eq({"t": "2010-01-01 02:03:04.555555"},
       st({"t": datetime(2010, 1, 1, 2, 3, 4, 555555)}))
    eq({"nested": {
        "t": "2010-01-01 02:03:04.555555"
    }}, st({"nested": {
        "t": datetime(2010, 1, 1, 2, 3, 4, 555555)
    }}))

    # Tuples
    eq((), st(()))
    eq(("a", 1), st(("a", 1)))
    eq(("t", "2010-01-01 02:03:04.555555"),
       st(("t", datetime(2010, 1, 1, 2, 3, 4, 555555))))
Beispiel #8
0
def test_orn():
    eq(True, orn(True, False, True))