Skip to content

Commit

Permalink
ConsolePrinterTest: Close printer object
Browse files Browse the repository at this point in the history
  • Loading branch information
sils committed Apr 8, 2015
1 parent e352abd commit a7a7399
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions coalib/tests/output/printers/ConsolePrinterTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

1 comment on commit a7a7399

@Makman2
Copy link
Member

@Makman2 Makman2 commented on a7a7399 Apr 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

Please sign in to comment.