def test_library_initialization(): """Test library initialization. """ def _test_init_01(): """Normal initialization.""" with tu.get_options() as opts: LIB.init(opts) @nose.tools.raises(IOError) def _test_init_02(): """Initialization error caused by invalid io directory.""" LIB.init({ 'io_dir': uuid.uuid4() }) @nose.tools.raises(ValueError) def _test_init_03(): """Initialization error caused by invalid verbose flag.""" LIB.init({ 'verbose': float() }) for func in (_test_init_01, _test_init_02, _test_init_03): tu.init(func, 'library') yield func
def test_library_exports(): """Test set of exports exposed by library. """ def _test_member(member, member_type): """Test that library exposes the named member.""" assertor = getattr(tu, 'assert_has_{}'.format(member_type)) assertor(LIB, member) for members, member_type, in ( (_CLASSES, 'class'), (_CONSTANTS, 'constant'), (_EXCEPTIONS, 'exception'), (_FUNCS, 'function'), ): for member in members: desc = "exposes a {} called {}".format(member_type, member) tu.init(_test_member, 'library', desc) yield _test_member, member, member_type