Changeset - 1828ea5794c5
[Not reviewed]
default
0 1 1
Laman - 7 years ago 2017-10-19 12:38:21

tests: redirected output and logging
2 files changed with 19 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/tests/data/test4.img
Show inline comments
 
new file 100644
 
binary diff not shown
src/tests/test_overall.py
Show inline comments
 
import os
 
import sys
 
import shutil
 
import hashlib
 
import multiprocessing
 
from logging import FileHandler
 
from unittest import TestCase
 

	
 
import config
 
@@ -10,6 +12,13 @@ from client import Client, Connection as
 
from server import Miniserver
 

	
 

	
 
config.logger.removeHandler(config.handler)
 
handler=FileHandler("/tmp/morevna.log")
 
handler.setFormatter(config.formatter)
 
config.logger.addHandler(handler)
 

	
 
config.batchSize=8
 

	
 
dataDir=os.path.join(config.directory,"src/tests/data")
 
filename=os.path.join(dataDir,"test.img")
 

	
 
@@ -23,6 +32,13 @@ def compareFiles(f1,f2):
 

	
 

	
 
class TestMorevna(TestCase):
 
	_stdout=None
 

	
 
	@classmethod
 
	def setUpClass(cls):
 
		cls._stdout=sys.stdout
 
		sys.stdout=open("/tmp/morevna-stdout.log",mode="a")
 

	
 
	def setUp(self):
 
		src=os.path.join(dataDir,"test1.img")
 
		shutil.copyfile(src,filename)
 
@@ -30,6 +46,8 @@ class TestMorevna(TestCase):
 
	@classmethod
 
	def tearDownClass(cls):
 
		os.remove(filename)
 
		sys.stdout.close()
 
		sys.stdout=cls._stdout
 

	
 
	def test_build(self):
 
		treeFile=os.path.join(dataDir,"test.bin")
 
@@ -47,7 +65,7 @@ class TestMorevna(TestCase):
 
		p=multiprocessing.Process(target=ms.serve)
 
		p.start()
 

	
 
		for clientFile in ("test2.img","test3.img"):
 
		for clientFile in ("test2.img","test3.img","test4.img"):
 
			clientFile=os.path.join(dataDir,clientFile)
 
			c=Client(clientFile)
 
			with ClientConnection() as con:
0 comments (0 inline, 0 general)