mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 17:34:32 +02:00
Moved fixtures to fixtures.py, added .schema test
This commit is contained in:
parent
f5418e13f2
commit
c446e22f34
3 changed files with 29 additions and 25 deletions
22
tests/fixtures.py
Normal file
22
tests/fixtures.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
from sqlite_utils import Database
|
||||
import sqlite3
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fresh_db():
|
||||
return Database(sqlite3.connect(":memory:"))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def existing_db():
|
||||
database = Database(sqlite3.connect(":memory:"))
|
||||
database.conn.executescript(
|
||||
"""
|
||||
CREATE TABLE foo (text TEXT);
|
||||
INSERT INTO foo (text) values ("one");
|
||||
INSERT INTO foo (text) values ("two");
|
||||
INSERT INTO foo (text) values ("three");
|
||||
"""
|
||||
)
|
||||
return database
|
||||
|
|
@ -1,12 +1,6 @@
|
|||
from sqlite_utils import Database
|
||||
import json
|
||||
import sqlite3
|
||||
from .fixtures import fresh_db
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fresh_db():
|
||||
return Database(sqlite3.connect(":memory:"))
|
||||
import json
|
||||
|
||||
|
||||
def test_create_table(fresh_db):
|
||||
|
|
|
|||
|
|
@ -1,20 +1,4 @@
|
|||
from sqlite_utils import Database
|
||||
import sqlite3
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def existing_db():
|
||||
database = Database(sqlite3.connect(":memory:"))
|
||||
database.conn.executescript(
|
||||
"""
|
||||
CREATE TABLE foo (text TEXT);
|
||||
INSERT INTO foo (text) values ("one");
|
||||
INSERT INTO foo (text) values ("two");
|
||||
INSERT INTO foo (text) values ("three");
|
||||
"""
|
||||
)
|
||||
return database
|
||||
from .fixtures import existing_db
|
||||
|
||||
|
||||
def test_count(existing_db):
|
||||
|
|
@ -26,3 +10,7 @@ def test_columns(existing_db):
|
|||
assert [{"name": "text", "type": "TEXT"}] == [
|
||||
{"name": col.name, "type": col.type} for col in table.columns
|
||||
]
|
||||
|
||||
|
||||
def test_schema(existing_db):
|
||||
assert "CREATE TABLE foo (text TEXT)" == existing_db["foo"].schema
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue