def test_default_option_values(self): sna2ctl.main(('test.sna', )) snafile, options = run_args[:2] self.assertEqual(snafile, 'test.sna') self.assertEqual(options.ctl_hex, 0) self.assertIsNone(options.start) self.assertEqual(options.end, 65536) self.assertIsNone(options.code_map) self.assertIsNone(options.org) self.assertIsNone(options.page) self.assertEqual([], options.params)
def test_default_option_values(self): sna2ctl.main(('test.sna',)) snafile, options = run_args[:2] self.assertEqual(snafile, 'test.sna') self.assertEqual(options.ctl_hex, 0) self.assertEqual(options.start, 0) self.assertEqual(options.end, 65536) self.assertIsNone(options.code_map) self.assertIsNone(options.org) self.assertIsNone(options.page) self.assertEqual([], options.params)
def test_invalid_option_values_read_from_file(self): ini = """ [sna2ctl] Hex=? TextMinLengthCode=x TextMinLengthData=! """ self.write_text_file(dedent(ini).strip(), 'skoolkit.ini') sna2ctl.main(('test.sna', )) snafile, options, config = run_args self.assertEqual(snafile, 'test.sna') self.assertEqual(options.ctl_hex, 0) self.assertEqual(config['Hex'], 0) self.assertEqual(config['TextMinLengthCode'], 12) self.assertEqual(config['TextMinLengthData'], 3)
def test_invalid_option_values_read_from_file(self): ini = """ [sna2ctl] Hex=? TextMinLengthCode=x TextMinLengthData=! """ self.write_text_file(dedent(ini).strip(), 'skoolkit.ini') sna2ctl.main(('test.sna',)) snafile, options, config = run_args self.assertEqual(snafile, 'test.sna') self.assertEqual(options.ctl_hex, 0) self.assertEqual(config['Hex'], 0) self.assertEqual(config['TextMinLengthCode'], 12) self.assertEqual(config['TextMinLengthData'], 3)
def test_config_read_from_file(self): ini = """ [sna2ctl] Hex=1 TextChars=abcdefghijklmnopqrstuvwxyz """ self.write_text_file(dedent(ini).strip(), 'skoolkit.ini') sna2ctl.main(('test.sna', )) snafile, options, config = run_args self.assertEqual(snafile, 'test.sna') self.assertEqual(options.ctl_hex, 1) self.assertIsNone(options.start) self.assertEqual(options.end, 65536) self.assertIsNone(options.code_map) self.assertIsNone(options.org) self.assertIsNone(options.page) self.assertEqual(config['Hex'], 1) self.assertEqual(config['TextChars'], 'abcdefghijklmnopqrstuvwxyz')
def test_config_read_from_file(self): ini = """ [sna2ctl] Hex=1 TextChars=abcdefghijklmnopqrstuvwxyz """ self.write_text_file(dedent(ini).strip(), 'skoolkit.ini') sna2ctl.main(('test.sna',)) snafile, options, config = run_args self.assertEqual(snafile, 'test.sna') self.assertEqual(options.ctl_hex, 1) self.assertEqual(options.start, 0) self.assertEqual(options.end, 65536) self.assertIsNone(options.code_map) self.assertIsNone(options.org) self.assertIsNone(options.page) self.assertEqual(config['Hex'], 1) self.assertEqual(config['TextChars'], 'abcdefghijklmnopqrstuvwxyz')
#!/usr/bin/env python3 # Copyright 2018 Richard Dymond ([email protected]) # # This file is part of SkoolKit. # # SkoolKit is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # SkoolKit is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along with # SkoolKit. If not, see <http://www.gnu.org/licenses/>. import sys from skoolkit import sna2ctl, error, SkoolKitError try: sna2ctl.main(sys.argv[1:]) except SkoolKitError as e: error(e.args[0])