def test_invalid_command(self): working_dir = pathlib.Path().absolute() test_file = os.path.join(working_dir, "invalid.txt") temp_stdout = StringIO() with contextlib.redirect_stdout(temp_stdout): main([test_file]) output = temp_stdout.getvalue().splitlines() self.assertEqual(output[0], "Invalid Command INVALID")
def test_correct_calls(self, load, exchange): working_dir = pathlib.Path().absolute() test_file = os.path.join(working_dir, "input.txt") main([test_file]) self.assertTrue(exchange.called) self.assertEqual(4, exchange.call_count) self.assertTrue(load.called) self.assertEqual(2, load.call_count)
def test_correct_output(self): working_dir = pathlib.Path().absolute() test_file = os.path.join(working_dir, "input.txt") temp_stdout = StringIO() with contextlib.redirect_stdout(temp_stdout): main([test_file]) output = temp_stdout.getvalue().splitlines() self.assertEqual(output[0], "1 3 N") self.assertEqual(output[1], "5 1 E")
def test_incorrect_path(self): with self.assertRaises(SystemExit): working_dir = pathlib.Path().absolute() test_file = os.path.join(working_dir, "fake_gfg.txt") temp_stdout = StringIO() with contextlib.redirect_stdout(temp_stdout): main([test_file]) output = temp_stdout.getvalue().splitlines() self.assertEqual( output[0], "The path specified does not exist or " "is not a file")
__remake__ = 'Ashen' __url__ = 'imashen.cn' import pygame as pg from source.main import main if __name__ == '__main__': main() pg.quit()
#! /usr/bin/env python import sys from os.path import join sys.path.append(join('source', 'lib')) from source.main import main main()
def test_bad_date(): with pytest.raises(ValueError): main('tests/test_files/bad_date.csv')
def test_bad_columns(): with pytest.raises(ValueError) as ve: main('tests/test_files/bad_columns.csv')
def test_bad_event(): with pytest.raises(ValueError): main('tests/test_files/bad_event.csv')
def run(event, context): main()
#!/usr/bin/env python3 import sys import pygame from source import main if __name__ == '__main__': main.main() pygame.quit() sys.exit()
from source.main import main if __name__ == '__main__': main('input.csv')