Ejemplo n.º 1
0
    def test_load_bad_extension(self):
        example = {"a": "b"}

        with TestLoadFile.magic_wrap(example, ".bllakjf") as tmpfile:
            with patch("tavern.util.loader.os.path.join", return_value=tmpfile):
                with pytest.raises(exceptions.BadSchemaError):
                    construct_include(Mock(), Mock())
Ejemplo n.º 2
0
    def test_include_path(self):
        example = {"a": "b"}

        with TestLoadFile.magic_wrap(example, ".yaml") as tmpfile:
            tmppath, tmpfilename = os.path.split(tmpfile)
            with pytest.raises(exceptions.BadSchemaError):
                construct_include(
                    Mock(
                        _root="/does-not-exist", construct_scalar=lambda x: tmpfilename
                    ),
                    Mock(),
                )

            with patch("tavern.util.loader.IncludeLoader.env_path_list", None):
                assert example == construct_include(
                    Mock(_root=tmppath, construct_scalar=lambda x: tmpfilename), Mock()
                )

            os.environ[IncludeLoader.env_var_name] = tmppath
            with patch("tavern.util.loader.IncludeLoader.env_path_list", None):
                assert example == construct_include(
                    Mock(
                        _root="/does-not-exist", construct_scalar=lambda x: tmpfilename
                    ),
                    Mock(),
                )
Ejemplo n.º 3
0
    def test_load_extensions(self, suffix):
        example = {"a": "b"}

        with TestLoadFile.magic_wrap(example, suffix) as tmpfile:
            with patch("tavern.util.loader.os.path.join",
                       return_value=tmpfile):
                assert example == construct_include(Mock(), Mock())