Refactor and reformat
This commit is contained in:
parent
e96aa553fe
commit
750ba7b0d4
23 changed files with 122 additions and 71 deletions
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
zeroth_key="test"
|
||||
first_key=test
|
||||
first_key= András
|
||||
second_key = test 2 # comment is ignored
|
||||
third_key= "test= 2=="
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from great_ai.utilities.publication_tei.models import (
|
||||
from great_ai.utilities.publication_tei import (
|
||||
Affiliation,
|
||||
Author,
|
||||
Bookmark,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import unittest
|
||||
|
||||
from src.great_ai.utilities.clean import clean
|
||||
from src.great_ai.utilities import clean
|
||||
|
||||
|
||||
class TestClean(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from src.great_ai.utilities.config_file import ConfigFile
|
||||
|
||||
from src.great_ai.utilities import ConfigFile
|
||||
|
||||
DATA_PATH = Path(__file__).parent.resolve() / "data"
|
||||
|
||||
|
|
@ -9,38 +11,60 @@ DATA_PATH = Path(__file__).parent.resolve() / "data"
|
|||
class TestConfigFile(unittest.TestCase):
|
||||
def test_simple(self) -> None:
|
||||
c = ConfigFile(DATA_PATH / "good.conf")
|
||||
assert c.zeroth_key == 'test'
|
||||
assert c.first_key == 'test'
|
||||
assert c.second_key == 'test 2'
|
||||
assert c.third_key == 'test= 2=='
|
||||
assert c.fourth_key == '''
|
||||
assert c.zeroth_key == "test"
|
||||
assert c.first_key == "András"
|
||||
assert c.second_key == "test 2"
|
||||
assert c.third_key == "test= 2=="
|
||||
assert (
|
||||
c.fourth_key
|
||||
== """
|
||||
this#
|
||||
is
|
||||
multiline
|
||||
'''
|
||||
assert c.whitespace == 'hardly matters'
|
||||
|
||||
"""
|
||||
)
|
||||
assert c.whitespace == "hardly matters"
|
||||
|
||||
def test_simple_dict(self) -> None:
|
||||
c = ConfigFile(DATA_PATH / "good.conf")
|
||||
assert c["zeroth_key"] == "test"
|
||||
assert c["first_key"] == "András"
|
||||
assert c["second_key"] == "test 2"
|
||||
assert c["third_key"] == "test= 2=="
|
||||
assert (
|
||||
c["fourth_key"]
|
||||
== """
|
||||
this#
|
||||
is
|
||||
multiline
|
||||
"""
|
||||
)
|
||||
assert c["whitespace"] == "hardly matters"
|
||||
|
||||
def test_string_path(self) -> None:
|
||||
c = ConfigFile(str(DATA_PATH / "good.conf"))
|
||||
assert c.zeroth_key == 'test'
|
||||
assert c.first_key == 'test'
|
||||
assert c.second_key == 'test 2'
|
||||
assert c.third_key == 'test= 2=='
|
||||
assert c.fourth_key == '''
|
||||
assert c.zeroth_key == "test"
|
||||
assert c.first_key == "András"
|
||||
assert c.second_key == "test 2"
|
||||
assert c.third_key == "test= 2=="
|
||||
assert (
|
||||
c.fourth_key
|
||||
== """
|
||||
this#
|
||||
is
|
||||
multiline
|
||||
'''
|
||||
assert c.whitespace == 'hardly matters'
|
||||
"""
|
||||
)
|
||||
assert c.whitespace == "hardly matters"
|
||||
|
||||
def test_env(self) -> None:
|
||||
import os
|
||||
os.environ['alma'] = '12'
|
||||
|
||||
os.environ["alma"] = "12"
|
||||
c = ConfigFile(DATA_PATH / "env.conf")
|
||||
del os.environ['alma']
|
||||
assert c.first_key == 'test'
|
||||
assert c.second_key == '12'
|
||||
del os.environ["alma"]
|
||||
assert c.first_key == "test"
|
||||
assert c.second_key == "12"
|
||||
|
||||
def test_env_not_exists(self) -> None:
|
||||
with pytest.raises(KeyError):
|
||||
|
|
@ -48,9 +72,10 @@ multiline
|
|||
|
||||
def test_env_not_exists_but_ignored(self) -> None:
|
||||
with pytest.raises(KeyError):
|
||||
ConfigFile(DATA_PATH / "env.conf", ignore_missing_environment_variables=True)
|
||||
ConfigFile(
|
||||
DATA_PATH / "env.conf", ignore_missing_environment_variables=True
|
||||
)
|
||||
|
||||
def test_duplicate_key(self) -> None:
|
||||
with pytest.raises(KeyError):
|
||||
ConfigFile(DATA_PATH / "bad.conf")
|
||||
|
||||
|
|
@ -5,7 +5,7 @@ import matplotlib
|
|||
|
||||
matplotlib.use("Agg") # don't show a window for each test
|
||||
|
||||
from src.great_ai.utilities.evaluate_ranking import evaluate_ranking
|
||||
from src.great_ai.utilities import evaluate_ranking
|
||||
|
||||
|
||||
class TestEvaluateRanking(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import unittest
|
||||
|
||||
from src.great_ai.utilities.get_sentences import get_sentences
|
||||
from src.great_ai.utilities import get_sentences
|
||||
|
||||
|
||||
class TestGetSentences(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import unittest
|
||||
|
||||
from src.great_ai.utilities.language import (
|
||||
from src.great_ai.utilities import (
|
||||
english_name_of_language,
|
||||
is_english,
|
||||
predict_language,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import unittest
|
||||
|
||||
from src.great_ai.utilities.lemmatize_text import lemmatize_text
|
||||
from src.great_ai.utilities import lemmatize_text
|
||||
|
||||
|
||||
class TestLemmatizeText(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import unittest
|
||||
|
||||
from src.great_ai.utilities.lemmatize_text import lemmatize_token
|
||||
from src.great_ai.utilities.nlp import nlp
|
||||
from src.great_ai.utilities import lemmatize_token, nlp
|
||||
|
||||
|
||||
class TestLemmatizeToken(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import unittest
|
||||
|
||||
from src.great_ai.utilities.match_names.match_names import match_names
|
||||
from src.great_ai.utilities import match_names
|
||||
|
||||
|
||||
class TestMatchNames(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import unittest
|
||||
|
||||
from src.great_ai.utilities.parallel_map import parallel_map
|
||||
from src.great_ai.utilities import parallel_map
|
||||
|
||||
COUNT = int(1e5) + 3
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from src.great_ai.utilities.publication_tei import PublicationTEI
|
||||
from src.great_ai.utilities import PublicationTEI
|
||||
|
||||
from .data.parsed import (
|
||||
abstract,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import unittest
|
||||
|
||||
from src.great_ai.utilities.unique import unique
|
||||
from src.great_ai.utilities import unique
|
||||
|
||||
original = [
|
||||
("a", 1),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue