testLocation.py
import unittest
from Location import Location
import sys
import filecmp
class LocationTests(unittest.TestCase):
def test_print(self):
location = Location("code", "name", "country", "continent", 1, 2, 3, 4, 5)
temp = sys.stdout
sys.stdout = open('out/print_test.txt', 'w')
location.print()
sys.stdout.close()
sys.stdout = temp
assert filecmp.cmp('out/print_test.txt', 'expected/print_expected.txt') is True
def test_brief_print(self):
location = Location("code", "name", "country", "continent", 1, 2, 3, 4, 5)
temp = sys.stdout
sys.stdout = open('out/brief_print_test.txt', 'w')
location.brief_print()
sys.stdout.close()
sys.stdout = temp
assert filecmp.cmp('out/brief_print_test.txt', 'expected/brief_print_expected.txt') is True
if __name__ == '__main__':
unittest.main()