Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Reduce test complexity to work with memory available on GitHub actions

davidmezzetti1d353a28a3e4
diff --git a/test/python/testtranslation.py b/test/python/testtranslation.py
index 68048bad..c8142dbc 100644
--- a/test/python/testtranslation.py
+++ b/test/python/testtranslation.py
@@ -20,19 +20,15 @@ class TestTranslation(unittest.TestCase):
translate = Translation()
- # Validate translation from English - Spanish
text = "This is a test translation into Spanish"
translation = translate(text, "es")
- self.assertEqual(translation, "Esta es una traducción de prueba al español")
- # Validate no translation
- translation = translate("Esta es una traducción de prueba al español", "es")
- self.assertEqual(text, translation)
+ # Validate translation text
+ self.assertEqual(translation, "Esta es una traducción de prueba al español")
- # Validate long translation text
- text = "This is a test translation to Spanish. " * 100
- translation = translate(text, "es")
- self.assertIsNotNone(translation)
+ # Validate translation back
+ translation = translate(translation, "en")
+ self.assertEqual(translation, text)
@unittest.skipIf(os.name == "nt", "M2M100 skipped on Windows")
def testM2M100Translation(self):
@@ -46,3 +42,29 @@ class TestTranslation(unittest.TestCase):
# Validate translation text
self.assertEqual(text, "Ovo je testni prijevod na hrvatski")
+
+ def testNoTranslation(self):
+ """
+ Tests translation skipped when text already in destination language
+ """
+
+ translate = Translation()
+
+ text = "This is a test translation to English"
+ translation = translate(text, "en")
+
+ # Validate no translation
+ self.assertEqual(text, translation)
+
+ def testLongTranslation(self):
+ """
+ Tests a translation longer than max tokenization length.
+ """
+
+ translate = Translation()
+
+ text = "This is a test translation to Spanish. " * 100
+ translation = translate(text, "es")
+
+ # Validate translation text
+ self.assertIsNotNone(translation)
diff --git a/test/python/testwordvectors.py b/test/python/testwordvectors.py
index 51c8d7ca..ecf91b10 100644
--- a/test/python/testwordvectors.py
+++ b/test/python/testwordvectors.py
@@ -14,8 +14,7 @@ class TestWordVectors(unittest.TestCase):
Vectors tests
"""
- @classmethod
- def setUpClass(cls):
+ def setUp(self):
"""
Test a WordVectors build.
"""
@@ -24,10 +23,11 @@ class TestWordVectors(unittest.TestCase):
path = os.path.join(tempfile.gettempdir(), "vectors")
# Save model path
- cls.path = path + ".magnitude"
+ self.path = path + ".magnitude"
- # Build word vectors
- WordVectors.build("README.md", 300, 3, path)
+ if not os.path.exists(self.path):
+ # Build word vectors
+ WordVectors.build("README.md", 300, 3, path)
def testBlocking(self):
"""