Permalink
Browse files

update code_beatrix sue to changes in pyquickhelper 1.4

  • Loading branch information...
sdpython committed Mar 27, 2016
1 parent 45c76fd commit fe48039df59fb791e1ffa2634ddcf1e8c4559454
@@ -3,16 +3,13 @@
@brief run all unit tests
"""
import unittest
import os
import sys
import io
def main():
try:
import pyquickhelper
import pyensae
import pyquickhelper as skip_
except ImportError:
sys.path.append(
os.path.normpath(
@@ -23,19 +20,10 @@ def main():
"..",
"pyquickhelper",
"src"))))
import pyquickhelper
sys.path.append(
os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"pyensae",
"src"))))
import pyquickhelper
import pyquickhelper as skip_
from pyquickhelper import fLOG, run_cmd, main_wrapper_tests
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import main_wrapper_tests
fLOG(OutputPrint=True)
main_wrapper_tests(__file__)
@@ -6,7 +6,7 @@
import sys
import os
import unittest
import re
try:
import src
@@ -22,7 +22,7 @@
import src
try:
import pyquickhelper
import pyquickhelper as skip_
except ImportError:
path = os.path.normpath(
os.path.abspath(
@@ -35,9 +35,9 @@
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper
import pyquickhelper as skip_
from pyquickhelper import fLOG, get_temp_folder
from pyquickhelper.loghelper import fLOG
from src.code_beatrix.algorithm import voyageur_commerce_simple, distance_circuit, plot_circuit
@@ -73,7 +73,7 @@ def test_voyageur_commerce_simple(self):
if __name__ == "__main__":
import matplotlib.pyplot as plt
ax = plot_circuit(newp)
plot_circuit(newp)
plt.show()
if __name__ == "__main__":
@@ -22,7 +22,7 @@
import src
try:
import pyquickhelper
import pyquickhelper as skip_
except ImportError:
path = os.path.normpath(
os.path.abspath(
@@ -35,10 +35,11 @@
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper
import pyquickhelper as skip_
from pyquickhelper import fLOG, get_temp_folder
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import get_temp_folder
from pyquickhelper.helpgen import BlogPost, BlogPostList, BlogPostDirective
@@ -6,7 +6,6 @@
import sys
import os
import unittest
import re
try:
import src
@@ -22,7 +21,7 @@
import src
try:
import pyquickhelper
import pyquickhelper as skip_
except ImportError:
path = os.path.normpath(
os.path.abspath(
@@ -35,9 +34,10 @@
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper
import pyquickhelper as skip_
from pyquickhelper import fLOG, get_temp_folder
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import get_temp_folder
from src.code_beatrix.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_notebook, unittest_raise_exception_notebook
@@ -6,7 +6,7 @@
import sys
import os
import unittest
import re
try:
import src
@@ -22,7 +22,7 @@
import src
try:
import pyquickhelper
import pyquickhelper as skip_
except ImportError:
path = os.path.normpath(
os.path.abspath(
@@ -35,9 +35,10 @@
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper
import pyquickhelper as skip_
from pyquickhelper import fLOG, get_temp_folder
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import get_temp_folder
from src.code_beatrix.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_notebook, unittest_raise_exception_notebook
@@ -6,7 +6,7 @@
import sys
import os
import unittest
import re
try:
import src
@@ -22,7 +22,7 @@
import src
try:
import pyquickhelper
import pyquickhelper as skip_
except ImportError:
path = os.path.normpath(
os.path.abspath(
@@ -35,9 +35,9 @@
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper
import pyquickhelper as skip_
from pyquickhelper import fLOG, get_temp_folder
from pyquickhelper.loghelper import fLOG
from src.code_beatrix.ipythonhelper import local_d3js
@@ -5,7 +5,6 @@
import sys
import os
import unittest
import re
import warnings
@@ -23,7 +22,7 @@
import src
try:
import pyquickhelper
import pyquickhelper as skip_
except ImportError:
path = os.path.normpath(
os.path.abspath(
@@ -36,11 +35,10 @@
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper
import pyquickhelper as skip_
from pyquickhelper import fLOG, explore_folder_iterfile
from pyquickhelper.ipythonhelper import upgrade_notebook
from pyquickhelper.loghelper import fLOG
from src.code_beatrix.jsscripts import copy_jstool2ipython
@@ -5,7 +5,6 @@
import sys
import os
import unittest
import re
try:
@@ -22,7 +21,7 @@
import src
try:
import pyquickhelper
import pyquickhelper as skip_
except ImportError:
path = os.path.normpath(
os.path.abspath(
@@ -35,10 +34,11 @@
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper
import pyquickhelper as skip_
from pyquickhelper import fLOG, explore_folder_iterfile
from pyquickhelper.loghelper import fLOG
from pyquickhelper.filehelper import explore_folder_iterfile
from pyquickhelper.ipythonhelper import upgrade_notebook
@@ -5,25 +5,11 @@
import sys
import os
import unittest
import re
import flake8
import warnings
try:
import src
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..")))
if path not in sys.path:
sys.path.append(path)
import src
try:
import pyquickhelper
import pyquickhelper as skip_
except ImportError:
path = os.path.normpath(
os.path.abspath(
@@ -33,46 +19,58 @@
"..",
"..",
"pyquickhelper",
"src")))
"src",)))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper
import pyquickhelper as skip_
from pyquickhelper import fLOG, run_cmd
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import check_pep8
from pyquickhelper.pycode.utils_tests import _extended_refectoring
class TestFlake8(unittest.TestCase):
def test_flake8(self):
def test_flake8_src(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
if sys.version_info[0] == 2 or "Anaconda" in sys.executable \
or "condavir" in sys.executable:
warnings.warn(
"skipping test_flake8 because of Python 2 or " + sys.executable)
return
thi = os.path.abspath(os.path.dirname(__file__))
src_ = os.path.normpath(os.path.join(thi, "..", "..", "src"))
check_pep8(src_, fLOG=fLOG, extended=[("fLOG", _extended_refectoring)],
neg_filter=".*faq_python.py$")
def test_flake8_test(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
if sys.version_info[0] == 2 or "Anaconda" in sys.executable \
or "condavir" in sys.executable:
warnings.warn(
"skipping test_flake8 because of Python 2 or " + sys.executable)
return
thi = os.path.abspath(os.path.dirname(__file__))
src = os.path.normpath(os.path.join(thi, "..", "..", "src"))
exe = os.path.dirname(sys.executable)
scr = os.path.join(exe, "Scripts")
fla = os.path.join(scr, "flake8")
cmd = fla + " " + src
out, err = run_cmd(cmd, fLOG=fLOG, wait=True)
test = os.path.normpath(os.path.join(thi, "..", ))
check_pep8(test, fLOG=fLOG, neg_filter="temp_.*",
skip=["'src' imported but unused",
"'skip_' imported but unused",
"'skip__' imported but unused",
"'skip___' imported but unused",
],
extended=[("fLOG", _extended_refectoring)],
max_line_length=320)
lines = out.split("\n")
lines = [_ for _ in lines if "E501" not in _ and "__init__.py" not in _ and "E265" not in _
and "W291" not in _ and "W293" not in _]
lines = [_ for _ in lines if len(_) > 1]
if __name__ == "__main__":
for l in lines:
spl = l.split(":")
if len(spl[0]) == 1:
spl[1] = ":".join(spl[0:2])
del spl[0]
print(
' File "{0}", line {1}, {2}'.format(spl[0], spl[1], spl[-1]))
if len(lines) > 1:
raise Exception(
"{0} lines\n{1}".format(len(lines), "\n".join(lines)))
if __name__ == "__main__":
unittest.main()
Oops, something went wrong.

0 comments on commit fe48039

Please sign in to comment.