This repository was archived by the owner on Aug 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +18
-9
lines changed
Expand file tree Collapse file tree 4 files changed +18
-9
lines changed Original file line number Diff line number Diff line change 11from databases .core import Database , DatabaseURL
22
3- __version__ = "0.2.3 "
3+ __version__ = "0.2.4 "
44__all__ = ["Database" , "DatabaseURL" ]
Original file line number Diff line number Diff line change @@ -362,7 +362,10 @@ def netloc(self) -> typing.Optional[str]:
362362
363363 @property
364364 def database (self ) -> str :
365- return self .components .path .lstrip ("/" )
365+ path = self .components .path
366+ if path .startswith ("/" ):
367+ path = path [1 :]
368+ return path
366369
367370 @property
368371 def options (self ) -> dict :
Original file line number Diff line number Diff line change @@ -51,3 +51,9 @@ def test_replace_database_url_components():
5151 new = u .replace (database = "test_" + u .database )
5252 assert new .database == "test_mydatabase"
5353 assert str (new ) == "sqlite:///test_mydatabase"
54+
55+ u = DatabaseURL ("sqlite:////absolute/path" )
56+ assert u .database == "/absolute/path"
57+ new = u .replace (database = u .database + "_test" )
58+ assert new .database == "/absolute/path_test"
59+ assert str (new ) == "sqlite:////absolute/path_test"
Original file line number Diff line number Diff line change 44
55
66def test_invalid_format ():
7- with pytest .raises (ImportFromStringError ) as exc :
7+ with pytest .raises (ImportFromStringError ) as exc_info :
88 import_from_string ("example:" )
99 expected = 'Import string "example:" must be in format "<module>:<attribute>".'
10- assert exc .match (expected )
10+ assert exc_info .match (expected )
1111
1212
1313def test_invalid_module ():
14- with pytest .raises (ImportFromStringError ) as exc :
14+ with pytest .raises (ImportFromStringError ) as exc_info :
1515 import_from_string ("module_does_not_exist:myattr" )
1616 expected = 'Could not import module "module_does_not_exist".'
17- assert exc .match (expected )
17+ assert exc_info .match (expected )
1818
1919
2020def test_invalid_attr ():
21- with pytest .raises (ImportFromStringError ) as exc :
21+ with pytest .raises (ImportFromStringError ) as exc_info :
2222 import_from_string ("tempfile:attr_does_not_exist" )
2323 expected = 'Attribute "attr_does_not_exist" not found in module "tempfile".'
24- assert exc .match (expected )
24+ assert exc_info .match (expected )
2525
2626
2727def test_internal_import_error ():
28- with pytest .raises (ImportError ) as exc :
28+ with pytest .raises (ImportError ):
2929 import_from_string ("tests.importer.raise_import_error:myattr" )
3030
3131
You can’t perform that action at this time.
0 commit comments