How to use pathvalidate - 10 common examples

To help you get started, we’ve selected a few pathvalidate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thombashi / pathvalidate / test / test_filepath.py View on Github external
def test_normal(self, value, platform):
        validate_filepath(value, platform)
        assert is_valid_filepath(value, platform=platform)
github thombashi / pathvalidate / test / test_filepath.py View on Github external
def test_normal_path_separator(self, platform, value, expected):
        sanitized = sanitize_filepath(value, platform=platform)
        assert sanitized == expected
        assert is_valid_filepath(sanitized, platform=platform)
github thombashi / pathvalidate / test / test_filepath.py View on Github external
def test_exception_type(self, value, expected):
        with pytest.raises(expected):
            sanitize_filepath(value)
        assert not is_valid_filepath(value)
github thombashi / pathvalidate / test / test_filepath.py View on Github external
def test_normal_space_or_period_at_tail(self, platform, value):
        validate_filepath(value, platform=platform)
        assert is_valid_filepath(value, platform=platform)
github thombashi / pathvalidate / test / test_filepath.py View on Github external
def test_normal_max_len(self, value, platform, max_len, expected):
        if expected is None:
            validate_filepath(value, platform=platform, max_len=max_len)
            assert is_valid_filepath(value, platform=platform, max_len=max_len)
            return

        with pytest.raises(ValidationError) as e:
            validate_filepath(value, platform=platform, max_len=max_len)
        assert e.value.reason == ErrorReason.INVALID_LENGTH
github thombashi / pathvalidate / test / test_filepath.py View on Github external
def test_normal_reserved_name_used_valid_place(self, value, platform):
        validate_filepath(value, platform=platform)
        assert is_valid_filepath(value, platform=platform)
github thombashi / pathvalidate / test / test_filepath.py View on Github external
def test_normal_auto_platform_linux(self, value, expected):
        if expected is None:
            validate_filepath(value, platform="auto")
            assert is_valid_filepath(value, platform="auto")
            return

        with pytest.raises(expected):
            validate_filepath(value, platform="auto")
github thombashi / pathvalidate / test / test_filepath.py View on Github external
def test_locale_jp(self, locale):
        from faker import Factory

        fake = Factory.create(locale=locale, seed=1)

        for _ in range(100):
            filepath = fake.file_path()
            validate_filepath(filepath, platform="linux")
            assert is_valid_filepath(filepath, platform="linux")
github thombashi / pathvalidate / test / test_filename.py View on Github external
def test_normal_null_values(self, value, expected):
        assert sanitize_filename(value) == expected
github thombashi / pathvalidate / test / test_filename.py View on Github external
def test_normal_max_len(self, value, max_len, expected):
        filename = sanitize_filename(value, max_len=max_len)
        assert len(filename) == expected
        assert is_valid_filename(filename, max_len=max_len)