def test_context_object_multiple_returns(): with BiggerExample() as e2: eq(e2.s66, 66) eq(e2.one, 1) eq(e2.two, 2)
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)
def test_thread_context_manager(): with threadable(): eq(threading.active_count(), 2)
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]
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())
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))))
def test_orn(): eq(True, orn(True, False, True))