Check-in [66f8ffe0f8]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | basic system tests |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
66f8ffe0f85200441dcfd2a5036d24db |
User & Date: | mario 2022-10-21 06:20:46 |
Context
2022-10-21
| ||
08:16 | fix spliterate() to avert premature tail, empty segment check-in: b62eff5b3c user: mario tags: trunk | |
06:20 | basic system tests check-in: 66f8ffe0f8 user: mario tags: trunk | |
04:49 | test and fix systran and deepl, jettison deepl pro/api split (now decided on key suffix) check-in: cfa194ff57 user: mario tags: trunk | |
Changes
Added pytest.ini.
> > > > > > > | 1 2 3 4 5 6 7 | [pytest] minversion = 1.0 addopts = -ra -q --ignore=test/util.py --ignore=test/_*.py --ignore=test/__*.py -p no:warnings testpaths = test/ python_files = *.py # Yes sure pytest, why not do the obvious thing anyway python_functions = !_* [a-z]* [A-Z]* !_* |
Added test/-inherited_funcs.py.
> > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | class a: def x(): pass class b(a): def x(): None b = b() print(vars(a)) print(vars(b.__class__)) for func, code in vars(b.__class__).items(): if code not in vars(a).values(): print(func) print( dict(list(set(b.__class__.__dict__.items()) - set(a.__dict__.items()))).keys() ) |
Added test/argos.py.
> > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # encoding: utf-8 import init, os import translationbackends as tb kw = { "lang": "en", "from": "auto", "quick": 0, "quick": 0, "debug": 1, "mode": "page", "backend": "custom", "api_key": "", "email": "", "cmd": "", } def pons(): t = tb.ArgosNmt(**kw) assert t.translate("Jedes Ende ist auch ein Anfang.") == "Each end is also a beginning." |
Added test/assign.py.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # encoding: utf-8 import init, os import translationbackends as tb kw = { "lang": "en", "from": "auto", "quick": 0, "quick": 0, "debug": 1, "mode": "page", "api_key": "", "email": "", "cmd": "", } def _ab(backend): kw["backend"] = backend return tb.assign_service(kw) def google(): assert isinstance(_ab("google translate"), tb.GoogleWeb) assert isinstance(_ab("google ajax"), tb.GoogleAjax) def other(): assert isinstance(_ab("Argos"), tb.ArgosNmt) assert isinstance(_ab("Duck"), tb.DuckDuckGo) def deep(): for name in "DT: Google", "Pons Dict", "DT: Libre": assert isinstance(_ab(name), tb.DeepTranslator) assert isinstance(_ab("DTA: Any"), tb.DeepTransApi) |
Added test/cli.py.
> > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import init import translationbackends as tb kw = { "from": "auto", "lang": "en", "quick": 0, "debug": 1, "mode": "page", "backend": "custom", "api_key": "", "email": "", #"cmd": "", } def tr(): t = tb.CommandLine(cmd="echo -n -e {text}", **kw) assert t.translate("Abc") == "Abc" |
Added test/deepl.py.
> > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import init, os import translationbackends as tb kw = { "lang": "en", "from": "auto", "quick": 0, "quick": 0, "debug": 1, "mode": "page", "backend": "custom", "api_key": os.environ["DEEPL"], "email": "", "cmd": "", } def hello(): t = tb.DeeplApi(**kw) assert t.translate("Hilfe") == "Help" def cake(): t = tb.DeeplApi(**kw) assert t.translate("Der Kuchen wird kalt.") == "The cake is getting cold." |
Added test/duck.py.
> > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import init, os import translationbackends as tb kw = { "lang": "en", "from": "auto", "quick": 0, "quick": 0, "debug": 1, "mode": "page", "backend": "custom", "api_key": "", "email": "", "cmd": "", } def frog(): t = tb.DuckDuckGo(**kw) assert t.translate("Frosch tanzt") == "Frog dances" |
Added test/google.py.
> > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import init, os import translationbackends as tb kw = { "lang": "en", "from": "auto", "quick": 0, "quick": 0, "debug": 1, "mode": "page", "backend": "custom", "api_key": "", "email": "", "cmd": "", } def web(): t = tb.GoogleWeb(**kw) assert t.translate("kuchen") == "cake" def ajax(): t = tb.GoogleAjax(**kw) assert t.translate("kartoffel") == "potato" |
Added test/httpfaux.py.
> > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import init, os from httprequests import FauxRequests http = FauxRequests() def get(): resp = http.get("https://example.org/") assert resp.status_code == 200 assert resp.headers def post(): resp = http.post("https://httpbin.org/post", params={"a":"b", "c":"d"}) assert resp.json()["form"]["a"] == "b" def json(): resp = http.get("https://httpbin.org/json") assert resp.json() |
Added test/init.py.
> > > > | 1 2 3 4 | import sys sys.path.extend(["./pythonpath/", "../pythonpath/"]) import dotenv dotenv.load_dotenv() |
Added test/mymemory.py.
> > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # encoding: utf-8 import init, os import translationbackends as tb kw = { "lang": "fr", "from": "de", "quick": 0, "quick": 0, "debug": 1, "mode": "page", "backend": "custom", "api_key": "", "email": "", "cmd": "", } def pons(): t = tb.MyMemory(**kw) assert t.translate("streusselkuchen") == "Gâteau crumble" |
Added test/pons.py.
> > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import init, os import translationbackends as tb kw = { "lang": "it", "from": "de", "quick": 0, "quick": 0, "debug": 1, "mode": "page", "backend": "custom", "api_key": "", "email": "", "cmd": "", } def pons(): t = tb.PonsWeb(**kw) assert t.translate("umlauf") == "circolazione" |
Added test/systran.py.
> > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # encoding: utf-8 import init import translationbackends as tb import os kw = { "from": "auto", "lang": "en", "quick": 0, "debug": 1, "mode": "page", "backend": "custom", "api_key": os.environ["SYSTRAN"], "email": "", "cmd": "", } def st(): t = tb.SysTran(**kw) assert t.translate("Die Kuh schläft. Der Frosch tanzt.") == "The cow is asleep. The frog is dancing." |