Permalink
Browse files

fix a few bugs, extend unit test coverage

  • Loading branch information...
sdpython committed Apr 16, 2016
1 parent 81d4171 commit beaa8ece565067393ef868a01922739d1b6c91c6
@@ -0,0 +1,57 @@
"""
@brief test log(time=4s)
@author Xavier Dupre
"""
import sys
import os
import unittest
from docutils.parsers.rst import directives
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 as skip_
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"..",
"pyquickhelper",
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper as skip_
from pyquickhelper.loghelper import fLOG
from src.code_beatrix.automation.notebook_const_helper import voyageur_de_commerce_points
class TestAutomationConstant(unittest.TestCase):
def test_constant(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
voyageur_de_commerce_points()
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,71 @@
"""
@brief test log(time=1s)
"""
import sys
import os
import unittest
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
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"..",
"pyquickhelper",
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper
from pyquickhelper.loghelper import fLOG
from src.code_beatrix.ipythonhelper.magic_scratch import MagicScratch
class TestMagicSnap(unittest.TestCase):
def test_magic_snap(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
if sys.version_info[0] == 2:
# the module returns the following error
# ENCODING ERROR WITH Python 2.7, will not fix it
return
else:
password = "unittest" * 2
this = os.path.abspath(__file__)
mg = MagicScratch()
cmd = "-W 500"
fLOG("**", cmd)
mg.add_context({"this": this})
res = mg.snap(cmd)
fLOG(res)
assert res is not None
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,57 @@
"""
@brief test log(time=0s)
"""
import sys
import os
import unittest
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 as skip_
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"..",
"pyquickhelper",
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper as skip_
from pyquickhelper.loghelper import fLOG
from src.code_beatrix.scratchs import check
class TestCheckScratchFiles(unittest.TestCase):
def test_check(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
check()
if __name__ == "__main__":
unittest.main()
@@ -10,6 +10,6 @@ def check_chute():
basic checkings
"""
dirname = os.path.dirname(__file__)
f0 = os.path.exists(dirname, "chute.sb2")
f0 = os.path.join(dirname, "chute.sb2")
if not os.path.exists(f0):
raise FileNotFoundError(f0)
@@ -10,9 +10,9 @@ def check_echiquier():
basic checkings
"""
dirname = os.path.dirname(__file__)
f1 = os.path.exists(dirname, "echiquier.sb2")
f1 = os.path.join(dirname, "echiquier.sb2")
if not os.path.exists(f1):
raise FileNotFoundError(f1)
f0 = os.path.exists(dirname, "echiquier0.sb2")
f0 = os.path.join(dirname, "echiquier0.sb2")
if not os.path.exists(f0):
raise FileNotFoundError(f0)
@@ -10,12 +10,12 @@ def check_pyramide():
basic checkings
"""
dirname = os.path.dirname(__file__)
f1 = os.path.exists(dirname, "pyramide.sb2")
f1 = os.path.join(dirname, "pyramide.sb2")
if not os.path.exists(f1):
raise FileNotFoundError(f1)
f0 = os.path.exists(dirname, "pyramide0.sb2")
f0 = os.path.join(dirname, "pyramide0.sb2")
if not os.path.exists(f0):
raise FileNotFoundError(f0)
f2 = os.path.exists(dirname, "pyramide_bio.sb2")
f2 = os.path.join(dirname, "pyramide_bio.sb2")
if not os.path.exists(f2):
raise FileNotFoundError(f2)
@@ -10,9 +10,9 @@ def check_tri():
basic checkings
"""
dirname = os.path.dirname(__file__)
f1 = os.path.exists(dirname, "bubble_sort.sb2")
f1 = os.path.join(dirname, "bubble_sort.sb2")
if not os.path.exists(f1):
raise FileNotFoundError(f1)
f2 = os.path.exists(dirname, "bubble_sort0.sb2")
f2 = os.path.join(dirname, "bubble_sort0.sb2")
if not os.path.exists(f2):
raise FileNotFoundError(f2)

0 comments on commit beaa8ec

Please sign in to comment.