from tinydb import TinyDB, where
from tinydb.migrate import migrate

v1_0 = """
{
    "_default": [{"key": "value", "_id": 1}],
    "table": [{"key": "value", "_id": 2}]
}
"""


def test_upgrade(tmpdir):
    db_file = tmpdir.join('db.json')
    db_file.write(v1_0)

    # Run upgrade
    migrate(str(db_file))
    db = TinyDB(str(db_file))

    assert db.count(where('key') == 'value') == 1

@@ -1,16 +1,31 @@
+import pytest%0A%0A
 from tinydb impo
@@ -186,16 +186,267 @@
 %7D%0A%22%22%22%0A%0A%0A
+def test_open_old(tmpdir):%0A    # Make sure that opening an old database results in an exception and not%0A    # in data loss%0A    db_file = tmpdir.join('db.json')%0A    db_file.write(v1_0)%0A%0A    with pytest.raises(Exception):%0A        TinyDB(str(db_file))%0A%0A%0A
 def test

Test that opening an old database fails