Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_exception_reserved_valid(self, value, expected):
with pytest.raises(expected):
validate_sqlite_table_name(value)
def test_exception_type(self, value, expected):
with pytest.raises(expected):
validate_sqlite_table_name(value)
def test_normal_utf8(self, value):
validate_sqlite_table_name(value)
def test_exception_invalid_win_char(self, value):
with pytest.raises(InvalidCharError):
validate_sqlite_table_name(value)
def test_exception_reserved_invalid_name(self, value, expected):
with pytest.raises(expected):
validate_sqlite_table_name(value)
def _validate_table_name(self, table_name):
try:
pv.validate_sqlite_table_name(table_name)
except pv.ValidReservedNameError:
pass
except (pv.InvalidReservedNameError, pv.InvalidCharError) as e:
raise InvalidTableNameError(e)
def _sanitize_table_name(self, table_name):
try:
pathvalidate.validate_sqlite_table_name(table_name)
return table_name
except pathvalidate.ReservedNameError:
return "{:s}_{:s}".format(table_name, self.format_name)
except pathvalidate.InvalidCharError as e:
raise InvalidTableNameError(e)