Permalink
Browse files

split again to fix a bug with python 36

  • Loading branch information...
sdpython committed Jun 15, 2017
1 parent 3c4d22a commit 4b97ab220ade2d30144555d2830f32a471938b8f
Showing with 99 additions and 51 deletions.
  1. +2 −51 _unittests/ut_algorithm/test_classroom.py
  2. +97 −0 _unittests/ut_algorithm/test_classroom_short.py
@@ -37,61 +37,12 @@
sys.path.append(path)
import pyquickhelper as skip_
from pyquickhelper.loghelper import fLOG, CustomLog
from pyquickhelper.pycode import get_temp_folder, fix_tkinter_issues_virtualenv
from src.code_beatrix.algorithm.data import load_prenoms_w
from src.code_beatrix.algorithm.classroom import random_positions, plot_positions, find_best_positions_greedy, measure_positions
from pyquickhelper.loghelper import fLOG
from src.code_beatrix.algorithm.classroom import find_best_positions_greedy, measure_positions
class TestClassRoom(unittest.TestCase):
def test_names(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
names = load_prenoms_w()
self.assertEqual(len(names), 50)
def test_random_position(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_random_position")
clog = CustomLog(temp)
clog("random_positions")
fLOG("random_positions")
positions = random_positions(24)
self.assertEqual(len(positions), 24)
clog("beginning")
fLOG("beginning")
fix_tkinter_issues_virtualenv()
clog("fix")
fLOG("fix")
import matplotlib.pyplot as plt
clog("plotting")
fLOG("plotting")
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8, 8))
clog("plotting positions")
fLOG("plotting positions")
plot_positions(positions, ax=ax)
self.assertTrue(ax is not None)
clog("savefig")
img = os.path.join(temp, "img.png")
fig.savefig(img)
self.assertTrue(os.path.exists(img))
clog("noshow")
if __name__ == "__main__":
fig.show()
clog("close")
plt.close('all')
clog("end")
fLOG("end")
def test_find_greedy(self):
fLOG(
__file__,
@@ -0,0 +1,97 @@
#-*- coding: utf-8 -*-
"""
@brief test log(time=3s)
"""
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 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, CustomLog
from pyquickhelper.pycode import get_temp_folder, fix_tkinter_issues_virtualenv
from src.code_beatrix.algorithm.data import load_prenoms_w
from src.code_beatrix.algorithm.classroom import random_positions, plot_positions
class TestClassRoomShort(unittest.TestCase):
def test_names(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
names = load_prenoms_w()
self.assertEqual(len(names), 50)
def test_random_position(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_random_position")
clog = CustomLog(temp)
clog("random_positions")
fLOG("random_positions")
positions = random_positions(24)
self.assertEqual(len(positions), 24)
clog("beginning")
fLOG("beginning")
fix_tkinter_issues_virtualenv()
clog("fix")
fLOG("fix")
import matplotlib.pyplot as plt
clog("plotting")
fLOG("plotting")
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8, 8))
clog("plotting positions")
fLOG("plotting positions")
plot_positions(positions, ax=ax)
self.assertTrue(ax is not None)
clog("savefig")
img = os.path.join(temp, "img.png")
fig.savefig(img)
self.assertTrue(os.path.exists(img))
clog("noshow")
if __name__ == "__main__":
fig.show()
clog("close")
plt.close('all')
clog("end")
fLOG("end")
if __name__ == "__main__":
unittest.main()

0 comments on commit 4b97ab2

Please sign in to comment.