]> git.phdru.name Git - mimedecode.git/commitdiff
Feat(tests): Use tox for testing
authorOleg Broytman <phd@phdru.name>
Mon, 31 Jul 2017 21:46:01 +0000 (00:46 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 23 Aug 2017 19:24:55 +0000 (22:24 +0300)
MANIFEST.in
TODO
devscripts/requirements/requirements_tox.txt [new file with mode: 0644]
test/Makefile
test/html2txt.py
test/test_all
tox.ini [new file with mode: 0644]

index 8e8e5154e957b079622507264b56849fc49a43ea..f80c0d1c0fbce4e61c16734375a6de6a64aeb3c0 100644 (file)
@@ -1,4 +1,5 @@
 global-include Makefile* *.py *.txt
 include ANNOUNCE ChangeLog MANIFEST.in TODO
-include mimedecode.docbook mimedecode.man mimedecode.html mk-distr
+include mimedecode.docbook mimedecode.man mimedecode.html
+include mk-distr tox.ini
 include test/.mailcap test/README test/test_all
diff --git a/TODO b/TODO
index e9223a104c15ef1d958dd3391964b35565541328..d8c3457abf9f6ce9b9b15cd3ce0d265c5a9e7483 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,3 @@
-tox.
-
-
 flake8.
 
 
diff --git a/devscripts/requirements/requirements_tox.txt b/devscripts/requirements/requirements_tox.txt
new file mode 100644 (file)
index 0000000..9927ea4
--- /dev/null
@@ -0,0 +1 @@
+tox >= 1.8
index fc8fe4525fc6c586927811085b0abdce680f1375..88ee55d667b00e532086ab53befd5b247d6cde96 100644 (file)
@@ -1,8 +1,7 @@
 
 .PHONY: all
 all:
-       PYTHON=python2 ./test_all
-       PYTHON=python3 ./test_all
+       ./test_all
 
 
 .PHONY: clean
index 4fa49f8cb931067cee9c43fe4f43c949d26c1bed..6b47f77b4d3c80d94645e5ef6bae6feecf4a6718 100755 (executable)
@@ -4,11 +4,21 @@ from __future__ import print_function
 import sys
 from m_lib.net.www.html import HTMLFilter
 
-with open(sys.argv[1], 'r') as f:
-    html = f.read()
+PY2 = sys.version_info[0] < 3
+if PY2:
+    with open(sys.argv[1], 'r') as f:
+        html = f.read()
+else:
+    with open(sys.argv[1], 'r', encoding='utf-8') as f:
+        html = f.read()
 
 filter = HTMLFilter()
 filter.feed(html)
 filter.close()
 
-print(filter.accumulator)
+if PY2:
+    print(filter.accumulator)
+else:
+    if not isinstance(filter.accumulator, bytes):
+        filter.accumulator = filter.accumulator.encode('utf-8')
+    sys.stdout.buffer.write(filter.accumulator + b'\n')
index d5b06e1923b9bc4b1148af56d94d3005bcd086c8..df65454df9050d52c121c78a67a7c7bac33ba7fe 100755 (executable)
@@ -1,13 +1,18 @@
 #! /bin/sh
 
 cd "`dirname \"$0\"`" &&
-MAILCAPS="`pwd`"/.mailcap &&
-export MAILCAPS &&
-
 rm -rf save tmp &&
 mkdir tmp || exit 1
 
+LC_CTYPE=c.UTF-8 &&
+export LC_CTYPE &&
+
+MAILCAPS="`pwd`"/.mailcap &&
+export MAILCAPS &&
+
+: ${PYTHON:=python}
 RC=0
+
 if [ `$PYTHON -c "import sys; print(sys.version[0])"` -eq 2 ]; then
    PY3=NO
 else
diff --git a/tox.ini b/tox.ini
new file mode 100644 (file)
index 0000000..aa6b387
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,26 @@
+# Tox (http://tox.testrun.org/) is a tool for running tests
+# in multiple virtualenvs. This configuration file will run the
+# test suite on all supported python versions. To use it, "pip install tox"
+# and then run "tox" from this directory.
+
+[tox]
+envlist = py27, py33, py34, py35, py36, pypy
+skip_missing_interpreters=true
+toxworkdir={homedir}/.tox/mimedecode
+
+[testenv]
+basepython =
+    py27: {env:TOXPYTHON:python2.7}
+    py33: {env:TOXPYTHON:python3.3}
+    py34: {env:TOXPYTHON:python3.4}
+    py35: {env:TOXPYTHON:python3.5}
+    py36: {env:TOXPYTHON:python3.6}
+    pypy: {env:TOXPYTHON:pypy}
+deps =
+    -rdevscripts/requirements/requirements_tests.txt
+changedir = test
+commands =
+    {envpython} --version
+    {envpython} -c "import struct; print(struct.calcsize('P') * 8)"
+    ./test_all
+#whitelist_externals =