コード例 #1
0
ファイル: testclass.py プロジェクト: jricardo27/aloe
    def from_file(cls, file_):
        """
        Construct a test class from a feature file.
        """

        feature = TestFeature.from_file(file_)

        background = cls.make_background(feature.background)
        scenarios = [
            cls.make_scenario(scenario, i + 1)
            for i, scenario in enumerate(feature.scenarios)
        ]

        before_feature, after_feature = \
            CALLBACK_REGISTRY.before_after('feature')

        members = {
            'feature': feature,
            'background': background,
            'before_feature': staticmethod(before_feature),
            'after_feature': staticmethod(after_feature),
        }

        members.update({
            scenario.__name__: scenario
            for scenario in scenarios
        })

        class_name = identifier(feature.name)

        testclass = type(class_name, (cls,), members)
        testclass.feature.testclass = testclass
        return testclass
コード例 #2
0
    def from_file(cls, file_):
        """
        Construct a test class from a feature file.
        """

        feature = TestFeature.from_file(file_)

        background = cls.make_background(feature.background)
        scenarios = [
            example for i, scenario in enumerate(feature.scenarios)
            for example in cls.make_examples(scenario, i + 1)
        ]

        before_feature, after_feature = \
            CALLBACK_REGISTRY.before_after('feature')

        members = {
            'feature': feature,
            'background': background,
            'before_feature': staticmethod(before_feature),
            'after_feature': staticmethod(after_feature),
        }

        members.update({scenario.__name__: scenario for scenario in scenarios})

        class_name = identifier(feature.name)

        testclass = type(class_name, (cls, ), members)
        testclass.feature.testclass = testclass
        return testclass
コード例 #3
0
ファイル: testclass.py プロジェクト: kiawin/aloe
    def from_file(cls, file_):
        """
        Construct a test class from a feature file.
        """

        feature = Feature.from_file(
            file_,
            parser_class=TestGherkin,
        )

        background = cls.make_background(feature.background)
        scenarios = [
            cls.make_scenario(scenario, i + 1)
            for i, scenario in enumerate(feature.scenarios)
        ]

        before_feature, after_feature = \
            CALLBACK_REGISTRY.before_after('feature')

        members = {
            'feature': feature,
            'background': background,
            'before_feature': staticmethod(before_feature),
            'after_feature': staticmethod(after_feature),
        }

        members.update({scenario.__name__: scenario for scenario in scenarios})

        class_name = always_str(feature.name)

        return type(class_name, (cls, ), members)
コード例 #4
0
ファイル: plugin.py プロジェクト: wayfair/pytest-eucalyptus
def session_hooks():
    before_all, after_all = CALLBACK_REGISTRY.before_after("all")
    # setup_stuff
    before_all()
    yield
    # teardown_stuff
    after_all()
コード例 #5
0
ファイル: plugin.py プロジェクト: electroniceagle/aloe
    def ensure_before_callbacks(self):
        """
        Before the first test, run the "before all" callbacks.
        """

        if not hasattr(self, 'after_hook'):
            before_all, after_all = CALLBACK_REGISTRY.before_after('all')
            before_all()
            self.after_hook = after_all
コード例 #6
0
ファイル: plugin.py プロジェクト: kiawin/aloe
    def ensure_before_callbacks(self):
        """
        Before the first test, run the "before all" callbacks.
        """

        if not hasattr(self, 'after_hook'):
            before_all, after_all = CALLBACK_REGISTRY.before_after('all')
            before_all()
            self.after_hook = after_all