Commit 740d903a authored by Vincent Michel's avatar Vincent Michel

Update tests that depend on code formatting

parent e9c5c7bd
......@@ -294,7 +294,7 @@ class RoiCounters(object):
self._remove_rois(names)
def __contains__(self, name):
return self.has_key(name)
return name in self._save_rois
def __len__(self):
return len(self._save_rois)
......
......@@ -13,15 +13,14 @@ import os
sys.path.insert(
0,
os.path.abspath(
os.path.join(
os.path.dirname(__file__),
os.path.pardir, os.path.pardir)))
os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir)
),
)
from bliss.common import log
class wrapped_stdout:
def __init__(self):
self.output = cStringIO.StringIO()
self.real_stdout = sys.stdout
......@@ -35,7 +34,6 @@ class wrapped_stdout:
class wrapped_stderr:
def __init__(self):
self.output = cStringIO.StringIO()
self.real_stderr = sys.stderr
......@@ -49,15 +47,17 @@ class wrapped_stderr:
class TestLogging(unittest.TestCase):
def test_debug(self):
log.level(log.DEBUG)
with wrapped_stdout() as stdout:
log.debug("debugging test")
output = stdout.getvalue()
# Must suppress 13 firsts chars.
self.assertTrue(output.endswith(
"test_debug() (misc/test_logging.py, l.56): debugging test\n"))
self.assertTrue(
output.endswith(
"test_debug() (misc/test_logging.py, l.53): debugging test\n"
)
)
def test_error(self):
log.level(log.ERROR)
......@@ -69,9 +69,7 @@ class TestLogging(unittest.TestCase):
with wrapped_stdout() as stdout:
log.info("test")
output = stdout.getvalue()
self.assertEquals(
output,
"INFO: test\n")
self.assertEquals(output, "INFO: test\n")
def test_level(self):
self.assertEquals(log.level(log.INFO), log.INFO)
......@@ -83,11 +81,14 @@ class TestLogging(unittest.TestCase):
with wrapped_stderr() as stderr:
log.exception("excepted exception", raise_exception=False)
output = stderr.getvalue()
self.assertTrue(output.endswith(
"""tests/misc/test_logging.py", line 81, in test_exception
self.assertTrue(
output.endswith(
"""tests/misc/test_logging.py", line 79, in test_exception
raise RuntimeError("BLA")
RuntimeError: BLA
"""))
"""
)
)
def test_exception2(self):
try:
......@@ -98,5 +99,5 @@ RuntimeError: BLA
self.assertTrue(False)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
......@@ -33,7 +33,7 @@ def test_current_session(session):
def test_session_tree(beacon, capsys):
session = beacon.get("test_session2")
session.sessions_tree.show()
out1, err1 = capsys.readouterr()
out1, err1 = capsys.readouterr()
t = Tree()
t.create_node("test_session2", "test_session2")
t.create_node("test_session", "test_session", parent="test_session2")
......@@ -77,7 +77,7 @@ def test_load_script(beacon, capsys):
assert env_dict["load_script"] is not None
load_script = env_dict["load_script"]
load_script("script3", "test_session5")
assert env_dict.get("test_func") is not None
assert env_dict.get("test_func") is not None
from bliss.session.test_session5 import script3
assert script3.test_func
......@@ -99,7 +99,7 @@ def test_load_script_namespace(beacon):
session.close()
def test_prdef(beacon, capsys):
visible_func_code="\n\x1b[34;01mdef\x1b[39;49;00m \x1b[32;01mvisible_func\x1b[39;49;00m():\n \x1b[34;01mpass\x1b[39;49;00m\n\n"
visible_func_code = u"\n\x1b[34;01mdef\x1b[39;49;00m \x1b[32;01mvisible_func\x1b[39;49;00m():\n \x1b[34;01mpass\x1b[39;49;00m\n\n"
env_dict = dict()
session = beacon.get("test_session2")
session.setup(env_dict)
......
def _hidden_func():
pass
pass
def visible_func():
pass
def visible_func():
pass
from bliss.common.standard import *
# Do not remove this print (used in tests)
print 'TEST_SESSION2 INITIALIZED'
print "TEST_SESSION2 INITIALIZED"
#
load_script("script1")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment