Esempio n. 1
0
File: run.py Progetto: Julian/Ivoire
def run(config):
    """
    Time to run.

    """

    setup(config)

    if config.exitfirst:
        ivoire.current_result.failfast = True

    ivoire.current_result.startTestRun()

    for spec in config.specs:
        try:
            load_by_name(spec)
        except Exception:
            ivoire.current_result.addError(_ExampleNotRunning(),
                                           sys.exc_info())

    ivoire.current_result.stopTestRun()

    sys.exit(not ivoire.current_result.wasSuccessful())
Esempio n. 2
0
def run(config):
    """
    Time to run.

    """

    setup(config)

    if config.exitfirst:
        ivoire.current_result.failfast = True

    ivoire.current_result.startTestRun()

    for spec in config.specs:
        try:
            load_by_name(spec)
        except Exception:
            ivoire.current_result.addError(
                _ExampleNotRunning(), sys.exc_info()
            )

    ivoire.current_result.stopTestRun()

    sys.exit(not ivoire.current_result.wasSuccessful())
Esempio n. 3
0
from ivoire import describe, load
from ivoire.spec.util import ExampleWithPatch, mock

with describe(load.load_by_name, Example=ExampleWithPatch) as it:

    @it.before
    def before(test):
        test.path_exists = test.patchObject(load.os.path, "exists")
        test.load_from_path = test.patchObject(load, "load_from_path")
        test.__import__ = test.patchObject(load, "__import__", create=True)

    with it("loads paths") as test:
        test.path_exists.return_value = True
        load.load_by_name("foo")
        test.load_from_path.assert_called_once_with("foo")

    with it("loads modules") as test:
        test.path_exists.return_value = False
        load.load_by_name("foo")
        test.__import__.assert_called_once_with("foo")

with describe(load.load_from_path, Example=ExampleWithPatch) as it:

    @it.before
    def before(test):
        test.isdir = test.patchObject(load.os.path, "isdir")
        test.load_source = test.patchObject(load.imp, "load_source")
        test.path = "foo/bar"

    with it("discovers specs if given a directory") as test:
        test.isdir.return_value = True
Esempio n. 4
0
from ivoire import describe, load
from ivoire.spec.util import ExampleWithPatch, mock


with describe(load.load_by_name, Example=ExampleWithPatch) as it:
    @it.before
    def before(test):
        test.path_exists = test.patchObject(load.os.path, "exists")
        test.load_from_path = test.patchObject(load, "load_from_path")
        test.__import__ = test.patchObject(load, "__import__", create=True)

    with it("loads paths") as test:
        test.path_exists.return_value = True
        load.load_by_name("foo")
        test.load_from_path.assert_called_once_with("foo")

    with it("loads modules") as test:
        test.path_exists.return_value = False
        load.load_by_name("foo")
        test.__import__.assert_called_once_with("foo")


with describe(load.load_from_path, Example=ExampleWithPatch) as it:
    @it.before
    def before(test):
        test.isdir = test.patchObject(load.os.path, "isdir")
        test.load_source = test.patchObject(load.imp, "load_source")
        test.path = "foo/bar"

    with it("discovers specs if given a directory") as test:
        test.isdir.return_value = True