diff options
author | Anders Lorentsen <Phaqui@gmail.com> | 2017-11-07 00:47:43 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-11-07 00:47:43 (GMT) |
commit | a22a127458d75b9b7e65e058f5db5ff705df5696 (patch) | |
tree | 02671d0bdaea01716305c713cc3a67433318aed2 /Lib/sqlite3 | |
parent | edb13ae48c17210fa4b2d40a6833ca09db5c121b (diff) | |
download | cpython-a22a127458d75b9b7e65e058f5db5ff705df5696.zip cpython-a22a127458d75b9b7e65e058f5db5ff705df5696.tar.gz cpython-a22a127458d75b9b7e65e058f5db5ff705df5696.tar.bz2 |
bpo-31843: sqlite3.connect() now accepts PathLike objects as database name (#4299)
Diffstat (limited to 'Lib/sqlite3')
-rw-r--r-- | Lib/sqlite3/test/dbapi.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py index 12c9fb4..5332975 100644 --- a/Lib/sqlite3/test/dbapi.py +++ b/Lib/sqlite3/test/dbapi.py @@ -160,6 +160,17 @@ class ConnectionTests(unittest.TestCase): with self.assertRaises(AttributeError): self.cx.in_transaction = True + def CheckOpenWithPathLikeObject(self): + """ Checks that we can succesfully connect to a database using an object that + is PathLike, i.e. has __fspath__(). """ + self.addCleanup(unlink, TESTFN) + class Path: + def __fspath__(self): + return TESTFN + path = Path() + with sqlite.connect(path) as cx: + cx.execute('create table test(id integer)') + def CheckOpenUri(self): if sqlite.sqlite_version_info < (3, 7, 7): with self.assertRaises(sqlite.NotSupportedError): |