Example #1
0
 def test_extendparser(self, exit_mock):
     be = self._make_one()
     parser = Mock()
     arg_ret = Mock()
     parser.parse_args = Mock(return_value=(arg_ret, None))
     arg_ret.verbose = 1
     arg_ret.quiet = 1
     assert be.extend_parser(parser) is None
     assert exit_mock.call_args[0][0] == 0
Example #2
0
def io_logger():
    io = StringIO()
    args = Mock()
    args.verbose = 2
    assert args.verbose == 2
    handler, = setup_logging(args, io)
    handler.setFormatter(logging.Formatter("%(name)s: %(message)s"))
    logger.setLevel(logging.DEBUG)
    return io
    def test_default_path_no_features(self):
        config = Mock()
        config.paths = []
        config.verbose = True
        r = runner.Runner(config)

        fs = FsMock("features/steps/")
        with patch("os.path", fs):
            with patch("os.walk", fs.walk):
                assert_raises(ConfigError, r.setup_paths)
    def test_supplied_feature_directory_missing(self):
        config = Mock()
        config.paths = ["spam"]
        config.verbose = True
        r = runner.Runner(config)

        fs = FsMock()

        with patch("os.path", fs):
            with patch("os.walk", fs.walk):
                assert_raises(ConfigError, r.setup_paths)
    def test_supplied_feature_file_no_steps(self):
        config = Mock()
        config.paths = ["features/group1/foo.feature"]
        config.verbose = True
        r = runner.Runner(config)

        fs = FsMock("features/", "features/group1/", "features/group1/foo.feature")

        with patch("os.path", fs):
            with patch("os.walk", fs.walk):
                with r.path_manager:
                    assert_raises(ConfigError, r.setup_paths)
Example #6
0
    def test_default_path_no_features(self):
        config = Mock()
        config.paths = []
        config.verbose = True
        r = runner.Runner(config)

        fs = FsMock("features/steps/")
        with patch("os.path", fs):
            with patch("os.walk", fs.walk):
                # pylint: disable=E0602
                #   E0602   Undefined variable "assert_raises"
                assert_raises(ConfigError, r.setup_paths)
    def test_supplied_feature_directory_no_steps(self):
        config = Mock()
        config.paths = ["features/group1"]
        config.verbose = True
        r = runner.Runner(config)

        fs = FsMock("features/", "features/group1/", "features/group1/foo.feature")

        with patch("os.path", fs):
            with patch("os.walk", fs.walk):
                assert_raises(ConfigError, r.setup_paths)

        ok_(("isdir", os.path.join(fs.base, "features", "steps")) in fs.calls)
    def test_default_path_no_steps(self):
        config = Mock()
        config.paths = []
        config.verbose = True
        r = runner.Runner(config)

        fs = FsMock()

        # will look for a "features" directory and not find one
        with patch("os.path", fs):
            assert_raises(ConfigError, r.setup_paths)

        ok_(("isdir", os.path.join(fs.base, "features", "steps")) in fs.calls)
Example #9
0
    def test_supplied_feature_directory_missing(self):
        config = Mock()
        config.paths = ["spam"]
        config.verbose = True
        r = runner.Runner(config)

        fs = FsMock()

        with patch("os.path", fs):
            with patch("os.walk", fs.walk):
                # pylint: disable=E0602
                #   E0602   Undefined variable "assert_raises"
                assert_raises(ConfigError, r.setup_paths)
    def test_default_path(self):
        config = Mock()
        config.paths = []
        config.verbose = True
        r = runner.Runner(config)

        fs = FsMock("features/", "features/steps/", "features/group1/", "features/group1/foo.feature")

        with patch("os.path", fs):
            with patch("os.walk", fs.walk):
                with r.path_manager:
                    r.setup_paths()

        eq_(r.base_dir, os.path.abspath("features"))
Example #11
0
    def test_supplied_feature_file_no_steps(self):
        config = Mock()
        config.paths = ["foo.feature"]
        config.verbose = True
        r = runner.Runner(config)

        fs = FsMock("foo.feature")

        with patch("os.path", fs):
            with patch("os.walk", fs.walk):
                with r.path_manager:
                    # pylint: disable=E0602
                    #   E0602   Undefined variable "assert_raises"
                    assert_raises(ConfigError, r.setup_paths)
    def test_supplied_feature_directory(self):
        config = Mock()
        config.paths = ["features/group1"]
        config.verbose = True
        r = runner.Runner(config)

        fs = FsMock("features/", "features/group1/", "features/group1/foo.feature", "features/steps/")

        with patch("os.path", fs):
            with patch("os.walk", fs.walk):
                with r.path_manager:
                    r.setup_paths()

        ok_(("isdir", os.path.join(fs.base, "features", "steps")) in fs.calls)
        eq_(r.base_dir, os.path.join(fs.base, "features"))
Example #13
0
    def test_supplied_feature_directory_no_steps(self):
        config = Mock()
        config.paths = ["spam"]
        config.verbose = True
        r = runner.Runner(config)

        fs = FsMock("spam/", "spam/foo.feature")

        with patch("os.path", fs):
            with patch("os.walk", fs.walk):
                # pylint: disable=E0602
                #   E0602   Undefined variable "assert_raises"
                assert_raises(ConfigError, r.setup_paths)

        ok_(("isdir", os.path.join(fs.base, "spam", "steps")) in fs.calls)
    def test_supplied_feature_file(self):
        config = Mock()
        config.paths = ["foo.feature"]
        config.verbose = True
        r = runner.Runner(config)
        r.context = Mock()

        fs = FsMock("steps/", "foo.feature")

        with patch("os.path", fs):
            with patch("os.walk", fs.walk):
                with r.path_manager:
                    r.setup_paths()
        ok_(("isdir", os.path.join(fs.base, "steps")) in fs.calls)
        ok_(("isfile", os.path.join(fs.base, "foo.feature")) in fs.calls)

        eq_(r.base_dir, fs.base)