From a7a73992d0a5527ddb2fe7268f31b9a3a8ab4693 Mon Sep 17 00:00:00 2001 From: Lasse Schuirmann Date: Wed, 8 Apr 2015 07:26:48 +0200 Subject: [PATCH] ConsolePrinterTest: Close printer object --- .../tests/output/printers/ConsolePrinterTest.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/coalib/tests/output/printers/ConsolePrinterTest.py b/coalib/tests/output/printers/ConsolePrinterTest.py index f29c35fd37..d19c938fe4 100644 --- a/coalib/tests/output/printers/ConsolePrinterTest.py +++ b/coalib/tests/output/printers/ConsolePrinterTest.py @@ -14,22 +14,30 @@ def write(self, *args): class ConsolePrinterTestCase(unittest.TestCase): - def test_printing(self): + def setUp(self): self.uut = ConsolePrinter() + + def tearDown(self): + self.uut.close() + + def test_printing(self): self.uut.print("\ntest", "message", color="green") self.uut.print("\ntest", "message", color="greeeeen") self.uut.print("\ntest", "message") def test_pickling(self): - outputfile = os.path.join(tempfile.gettempdir(), "ConsolePrinterPickleTestFile") + outputfile = os.path.join(tempfile.gettempdir(), + "ConsolePrinterPickleTestFile") with open(outputfile, "wb") as f: - pickle.dump(ConsolePrinter(), f) + pickle.dump(self.uut, f) with open(outputfile, "rb") as f: obj = pickle.load(f) self.assertIsInstance(obj, ConsolePrinter) - obj.print("test") # print will use the output param, this will ensure that the printer is valid + # print uses the output param, this ensures that the printer is valid + obj.print("test") + obj.close() os.remove(outputfile)