コード例 #1
0
ファイル: test_core.py プロジェクト: eriknw/metafunc
def test_composed_reversed_new():
    metafunc('rcomp', hofs1, fofs1, composition=True, reverse=True)
    # (1) check simple import
    from rcomp.inc import one
    assert one() == 2
    # (2) check multi-import
    from rcomp.inc import one, two, three
    assert one() == 2
    assert two() == 3
    assert three() == 4
    # (3) check nested import
    from rcomp.inc.inc.inc.inc import one
    assert one() == 5
    # (4) check order
    from rcomp.inc.double import one
    assert one() == 3
    # (5) check attribute access
    import rcomp
    assert rcomp.triple.double.triple.double.one() == 36
    # (6) check renaming (just because)
    from rcomp.inc.inc.inc import one as one_plus_three
    assert one_plus_three() == 4
コード例 #2
0
ファイル: test_core.py プロジェクト: eriknw/metafunc
def test_mirror_module():
    sys.modules['empty1'] = imp.new_module('empty1')
    import empty1 as orig_empty
    meta_empty = metafunc('empty1', hofs1, fofs1, composition=True)
    import empty1 as new_empty
    assert orig_empty == meta_empty
    assert orig_empty == new_empty
    assert meta_empty.double.double.one() == 4
    from empty1.inc.inc.double import one
    assert one() == 6
    # don't override modules
    assert raises(ValueError, lambda: metafunc('empty1', hofs1, fofs1,
                                               composition=True))
コード例 #3
0
ファイル: test_core.py プロジェクト: eriknw/metafunc
def test_hof():
    metafunc('zmm.hofs', hofs2, fofs2, reverse=False)
    # (1) check simple import
    from zmm.hofs.doubled import one
    assert one() == 2
    # (2) check multi-import
    from zmm.hofs.doubled import one, two, three
    assert one() == 2
    assert two() == 4
    assert three() == 6
    # (3) check nested import
    from zmm.hofs.doubled.tripled.doubled import one
    assert one() == 12
    # (4) check order
    from zmm.hofs.incremented.doubled import one
    assert one() == 4
    # (5) check attribute access
    import zmm
    assert zmm.hofs.tripled.doubled.tripled.one() == 18
    # (6) check renaming (just because)
    from zmm.hofs.incremented.tripled import one as six
    assert six() == 6
コード例 #4
0
ファイル: test_core.py プロジェクト: eriknw/metafunc
def test_hof_reversed_new():
    metafunc('rhofs', hofs2, fofs2, reverse=True)
    # (1) check simple import
    from rhofs.doubled import one
    assert one() == 2
    # (2) check multi-import
    from rhofs.doubled import one, two, three
    assert one() == 2
    assert two() == 4
    assert three() == 6
    # (3) check nested import
    from rhofs.doubled.tripled.doubled import one
    assert one() == 12
    # (4) check order
    from rhofs.incremented.doubled import one
    assert one() == 3
    # (5) check attribute access
    import rhofs
    assert rhofs.tripled.doubled.tripled.one() == 18
    # (6) check renaming (just because)
    from rhofs.incremented.tripled import one as four
    assert four() == 4
コード例 #5
0
ファイル: test_core.py プロジェクト: fagan2888/metafunc
def test_composed_reversed_new():
    metafunc('rcomp', hofs1, fofs1, composition=True, reverse=True)
    # (1) check simple import
    from rcomp.inc import one
    assert one() == 2
    # (2) check multi-import
    from rcomp.inc import one, two, three
    assert one() == 2
    assert two() == 3
    assert three() == 4
    # (3) check nested import
    from rcomp.inc.inc.inc.inc import one
    assert one() == 5
    # (4) check order
    from rcomp.inc.double import one
    assert one() == 3
    # (5) check attribute access
    import rcomp
    assert rcomp.triple.double.triple.double.one() == 36
    # (6) check renaming (just because)
    from rcomp.inc.inc.inc import one as one_plus_three
    assert one_plus_three() == 4
コード例 #6
0
ファイル: test_core.py プロジェクト: fagan2888/metafunc
def test_mirror_module():
    sys.modules['empty1'] = imp.new_module('empty1')
    import empty1 as orig_empty
    meta_empty = metafunc('empty1', hofs1, fofs1, composition=True)
    import empty1 as new_empty
    assert orig_empty == meta_empty
    assert orig_empty == new_empty
    assert meta_empty.double.double.one() == 4
    from empty1.inc.inc.double import one
    assert one() == 6
    # don't override modules
    assert raises(ValueError,
                  lambda: metafunc('empty1', hofs1, fofs1, composition=True))
コード例 #7
0
ファイル: test_core.py プロジェクト: fagan2888/metafunc
def test_hof_reversed_new():
    metafunc('rhofs', hofs2, fofs2, reverse=True)
    # (1) check simple import
    from rhofs.doubled import one
    assert one() == 2
    # (2) check multi-import
    from rhofs.doubled import one, two, three
    assert one() == 2
    assert two() == 4
    assert three() == 6
    # (3) check nested import
    from rhofs.doubled.tripled.doubled import one
    assert one() == 12
    # (4) check order
    from rhofs.incremented.doubled import one
    assert one() == 3
    # (5) check attribute access
    import rhofs
    assert rhofs.tripled.doubled.tripled.one() == 18
    # (6) check renaming (just because)
    from rhofs.incremented.tripled import one as four
    assert four() == 4
コード例 #8
0
ファイル: test_core.py プロジェクト: fagan2888/metafunc
def test_hof():
    metafunc('zmm.hofs', hofs2, fofs2, reverse=False)
    # (1) check simple import
    from zmm.hofs.doubled import one
    assert one() == 2
    # (2) check multi-import
    from zmm.hofs.doubled import one, two, three
    assert one() == 2
    assert two() == 4
    assert three() == 6
    # (3) check nested import
    from zmm.hofs.doubled.tripled.doubled import one
    assert one() == 12
    # (4) check order
    from zmm.hofs.incremented.doubled import one
    assert one() == 4
    # (5) check attribute access
    import zmm
    assert zmm.hofs.tripled.doubled.tripled.one() == 18
    # (6) check renaming (just because)
    from zmm.hofs.incremented.tripled import one as six
    assert six() == 6
コード例 #9
0
ファイル: test_core.py プロジェクト: eriknw/metafunc
def test_module_input():
    mod = sys.modules['empty2'] = imp.new_module('empty2')
    meta_empty = metafunc(mod, hofs1, fofs1, composition=True)
    assert mod == meta_empty
    from empty2.inc.inc.inc import one
    assert one() == 4
コード例 #10
0
ファイル: test_core.py プロジェクト: fagan2888/metafunc
def test_module_input():
    mod = sys.modules['empty2'] = imp.new_module('empty2')
    meta_empty = metafunc(mod, hofs1, fofs1, composition=True)
    assert mod == meta_empty
    from empty2.inc.inc.inc import one
    assert one() == 4