Example #1
0
def test_exception_catch_for_an_unknown_place():

    parser = Parser(
        "Yop, donne moi les coordonnées du trou noir Sagittarius A*")

    place = Location(parser)

    with pytest_raises(UnknownPlaceError):
        place.get_location()
Example #2
0
def test_check_config_against_spec_or_exit_does_not_print_schema(
        capsys, spec_object):
    config = {"super_secret_token": "really_a_secret"}
    with pytest_raises(Exception) as ex_info:
        check_config_against_spec_or_exit(config, spec_object)
        exc = ex_info.value
        traceback.print_exception(type(exc), exc, exc.__traceback__)
        out, err = capsys.readouterr()
        assert "really_a_secret" not in out + err
Example #3
0
def test_import_from_file():
    from copy import deepcopy
    from pytest import raises as pytest_raises
    from tempfile import NamedTemporaryFile

    current_path = deepcopy(sys.path)
    with NamedTemporaryFile() as junk_fh:
        junk_path = junk_fh.name
        with pytest_raises(ImportError):
            module = import_from_file(junk_path)
        assert current_path == sys.path
Example #4
0
def test_import_from_file():
    from copy import deepcopy
    from pytest import raises as pytest_raises
    from tempfile import NamedTemporaryFile

    current_path = deepcopy(sys.path)
    with NamedTemporaryFile() as junk_fh:
        junk_path = junk_fh.name
        with pytest_raises(ImportError):
            module = import_from_file(junk_path)
        assert current_path == sys.path
Example #5
0
def test_incorrect_paramaters():
    with pytest_raises(ValueError):
        SCManagerAccessFlagMask(incorrect_parameter=False)

    with pytest_raises(ValueError):
        SCManagerAccessFlagMask(connect=True, incorrect_parameter=True)