Example #1
0
    def test_failure(self):
        """
        Test that a failing feature fails tests.
        """

        stream = str_io()

        self.assert_feature_fail('features/wrong_expectations.feature',
                                 stream=stream)

        # Check that the appropriate error messages were printed

        output = stream.getvalue()

        error_header = "FAIL: Add two numbers " + \
            "(features.wrong_expectations: Wrong expectations)"

        self.assertIn(error_header, output)

        feature_stack_frame = """
  File "features/wrong_expectations.feature", line 11, in Add two numbers
    Then the result should be 40 on the screen
        """.strip()

        self.assertIn(feature_stack_frame, output)

        step_stack_frame = """
  File "{root}/tests/simple_app/features/steps.py", line 60, in assert_result
    assert world.result == float(result)
AssertionError
        """.strip().format(root=dirname(dirname(dirname(__file__))))

        self.assertIn(step_stack_frame, output)
Example #2
0
    def run_features(self, *features, **kwargs):
        """
        Run the specified features.
        """

        # named keyword args and variable positional args aren't supported on
        # Python 2
        verbosity = kwargs.get('verbosity')
        stream = kwargs.get('stream')
        force_color = kwargs.get('force_color', False)

        if stream is None and isinstance(sys.stdout, CAPTURED_OUTPUTS):
            # Don't show results of running the inner tests if the outer Nose
            # redirects output
            stream = str_io()

        CALLBACK_REGISTRY.clear(priority_class=PriorityClass.USER)
        STEP_REGISTRY.clear()
        world.__dict__.clear()

        argv = ['aloe']

        if verbosity:
            argv += ['--verbosity', str(verbosity)]

        if force_color:
            argv += ['--color']

        argv += list(features)

        return TestRunner(exit=False, argv=argv, stream=stream)
Example #3
0
    def run_features(self, *features, **kwargs):
        """
        Run the specified features.
        """

        # named keyword args and variable positional args aren't supported on
        # Python 2
        verbosity = kwargs.get('verbosity')
        stream = kwargs.get('stream')
        force_color = kwargs.get('force_color', False)

        if stream is None and isinstance(sys.stdout, CAPTURED_OUTPUTS):
            # Don't show results of running the inner tests if the outer Nose
            # redirects output
            stream = str_io()

        CALLBACK_REGISTRY.clear(priority_class=PriorityClass.USER)
        STEP_REGISTRY.clear()
        world.__dict__.clear()

        argv = ['aloe']

        if verbosity:
            argv += ['--verbosity', str(verbosity)]

        if force_color:
            argv += ['--color']

        argv += list(features)

        return TestRunner(exit=False, argv=argv, stream=stream)