mirror of
https://github.com/rspeer/wordfreq.git
synced 2024-12-25 18:18:53 +00:00
3063b3915a
The test currently fails on Python 3, for some strange reason.
35 lines
1011 B
Python
35 lines
1011 B
Python
from nose.tools import eq_
|
|
from wordfreq.build import load_all_data
|
|
from wordfreq.query import wordlist_info
|
|
from wordfreq.transfer import download_and_extract_raw_data
|
|
from wordfreq import config
|
|
import os
|
|
import tempfile
|
|
import shutil
|
|
import sqlite3
|
|
|
|
|
|
def flatten_list_of_dicts(list_of_dicts):
|
|
things = [sorted(d.items()) for d in list_of_dicts]
|
|
return sorted(things)
|
|
|
|
|
|
def test_build():
|
|
"""
|
|
Ensure that the build process builds the same DB that gets distributed.
|
|
"""
|
|
if not os.path.exists(config.RAW_DATA_DIR):
|
|
download_and_extract_raw_data()
|
|
|
|
tempdir = tempfile.mkdtemp('.wordfreq')
|
|
try:
|
|
db_file = os.path.join(tempdir, 'test.db')
|
|
load_all_data(config.RAW_DATA_DIR, db_file)
|
|
conn = sqlite3.connect(db_file)
|
|
|
|
# Compare the information we got to the information in the default DB.
|
|
eq_(flatten_list_of_dicts(wordlist_info(conn)),
|
|
flatten_list_of_dicts(wordlist_info(None)))
|
|
finally:
|
|
shutil.rmtree(tempdir)
|