Skip to content

Commit

Permalink
prepare version 1.1.2 and fix tests (#163)
Browse files Browse the repository at this point in the history
* prepare version 1.1.2 and fix tests

* tests: add print on exception
  • Loading branch information
adbar authored Nov 19, 2024
1 parent 436d4ed commit be7435e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
12 changes: 12 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
History
=======

1.1.2
-----

- Fix cyclic import by @juanjoDiaz (#148)
- Fix language detector proportion_in_each_language results by @juanjoDiaz (#150)
- Init: use explicit re-exports (#151)
- Fix data written by dictionary pickler by @Dunedan (#156)
- Add demo rules for Latvian and Estonian (#154, #157)
- Remove deprecated langdetect submodule (#160)
- Test: remove dummy pickled data (#161)
- Language data: upgrade pickle to v5 (#162)


1.1.1
-----
Expand Down
2 changes: 1 addition & 1 deletion simplemma/__metadata__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
__author__ = "Adrien Barbaresi, Juanjo Diaz and contributors"
__email__ = "[email protected]"
__license__ = "MIT"
__version__ = "1.1.1"
__version__ = "1.1.2"
16 changes: 10 additions & 6 deletions tests/test_dictionary_pickler.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import os
import tempfile

from os import path, remove

from training import dictionary_pickler

TEST_DIR = os.path.abspath(os.path.dirname(__file__))
TEST_DIR = path.abspath(path.dirname(__file__))


def test_logic() -> None:
"""Test if certain code parts correspond to the intended logic."""
# dict generation
testfile = os.path.join(TEST_DIR, "data/zz.txt")
testfile = path.join(TEST_DIR, "data/zz.txt")
# simple generation, silent mode
mydict = dictionary_pickler._read_dict(testfile, "zz", silent=True)
assert len(mydict) == 3
mydict = dictionary_pickler._load_dict(
"zz", listpath=os.path.join(TEST_DIR, "data"), silent=True
"zz", listpath=path.join(TEST_DIR, "data"), silent=True
)
assert len(mydict) == 3
# log warning
Expand All @@ -35,11 +36,14 @@ def test_logic() -> None:
assert dictionary_pickler._determine_path("lists", "de").endswith("de.txt")

# dict pickling
listpath = os.path.join(TEST_DIR, "data")
listpath = path.join(TEST_DIR, "data")
os_handle, temp_outputfile = tempfile.mkstemp(suffix=".pkl", text=True)
dictionary_pickler._pickle_dict("zz", listpath, temp_outputfile)
dictionary_pickler._pickle_dict("zz", listpath, in_place=True)

# remove pickle file
filepath = dictionary_pickler._determine_pickle_path("zz")
os.remove(filepath)
try:
remove(filepath)
except (AttributeError, FileNotFoundError):
print("Pickle file already deleted")
2 changes: 0 additions & 2 deletions tests/test_language_detector.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Tests for Simplemma's language detection utilities."""

import pytest

from simplemma import LanguageDetector, in_target_language, langdetect
from simplemma.strategies import DefaultStrategy

Expand Down

0 comments on commit be7435e

Please sign in to comment.