def test_no_theme(self): parse_command_line() with self.assertLogs("wdom.themes", "INFO") as log: reload(default_theme) self.assertEqual(len(log.output), 1) self.assertTrue(log.records[0].msg.startswith("No theme")) self.assertTrue(log.records[0].msg.endswith("Use default theme.")) self.assertEqual(default_theme.Button, tag.Button)
def test_bs(self): sys.argv.extend(['--theme', 'bootstrap3']) parse_command_line() with self.assertLogs('wdom.themes', 'INFO') as log: reload(self.theme_mod) self.assertEqual(len(log.output), 1) self.assertEqual(log.records[0].msg, 'Use theme: bootstrap3') from wdom.themes import bootstrap3 self.assertEqual(self.theme_mod.Button, bootstrap3.Button)
def test_bs(self): sys.argv.extend(["--theme", "bootstrap3"]) parse_command_line() with self.assertLogs("wdom.themes", "INFO") as log: reload(default_theme) self.assertEqual(len(log.output), 1) self.assertEqual(log.records[0].msg, "Use theme: bootstrap3") from wdom.themes import bootstrap3 self.assertEqual(default_theme.Button, bootstrap3.Button)
def test_unknown_theme(self): sys.argv.extend(['--theme', 'unknown']) parse_command_line() with self.assertLogs('wdom.themes', 'WARN') as log: reload(self.theme_mod) self.assertEqual(len(log.output), 2) self.assertTrue(log.records[0].msg.startswith('Unknown theme')) self.assertTrue(log.records[1].msg.startswith('Available themes:')) self.assertIn('unknown', log.records[0].msg) self.assertIn('skeleton', log.records[1].msg) self.assertEqual(self.theme_mod.Button, tag.Button)
def test_unknown_theme(self): sys.argv.extend(["--theme", "unknown"]) parse_command_line() with self.assertLogs("wdom.themes", "WARN") as log: reload(default_theme) self.assertEqual(len(log.output), 2) self.assertTrue(log.records[0].msg.startswith("Unknown theme")) self.assertTrue(log.records[1].msg.startswith("Available themes:")) self.assertIn("unknown", log.records[0].msg) self.assertIn("skeleton", log.records[1].msg) self.assertEqual(default_theme.Button, tag.Button)
def test_no_theme(self): parse_command_line() with self.assertLogs('wdom.themes', 'INFO'): # should be no log reload(self.theme_mod)
def test_unknown_args(self): sys.argv.extend(['--test-args', 'a']) # no error/log when get unknown args with self.assertRaises(AssertionError): with self.assertLogs('wdom'): parse_command_line()
def test_debug_with_logging(self): sys.argv.extend(['--debug', '--logging', 'warn']) parse_command_line() logger = logging.getLogger('wdom') assert logger.getEffectiveLevel() == logging.WARN
def test_default_loglevel(self): parse_command_line() set_loglevel() logger = logging.getLogger("wdom") self.assertEqual(logger.getEffectiveLevel(), logging.INFO)
def setUp(self): super().setUp() options.parse_command_line()
def test_default_loglevel(self): parse_command_line() set_loglevel() logger = logging.getLogger('wdom') self.assertEqual(logger.getEffectiveLevel(), logging.INFO)
def test_debug_with_logging(self): sys.argv.extend(["--debug", "--logging", "warn"]) parse_command_line() logger = logging.getLogger("wdom") assert logger.getEffectiveLevel() == logging.WARN
def test_debug_without_logging(self): sys.argv.extend(["--debug"]) parse_command_line() logger = logging.getLogger("wdom") self.assertEqual(logger.getEffectiveLevel(), logging.DEBUG)
def test_loglevel(self, level_name, level): sys.argv.extend(["--logging", level_name]) parse_command_line() logger = logging.getLogger("wdom") self.assertEqual(logger.getEffectiveLevel(), level) reset_options()
var rect = elm.getBoundingClientRect() window.scrollTo(x, rect.top + window.scrollY) console.log(elm.textContent) } } ''' mount_point = Div(parent=doc.body, class_='container') mount_point.appendChild(H2('LiveMark is running...')) app = get_app(doc) app.add_static_path('static', static_dir) for _d in _user_static_dirs: app.add_static_path(_d, _d) web_server = start_server(app, port=options.config.browser_port) loop = asyncio.get_event_loop() vim_server = Server(port=options.config.vim_port, loop=loop, doc=doc, mount_point=mount_point) browser = webbrowser.get(options.config.browser) browser.open('http://localhost:{}'.format(options.config.browser_port)) try: vim_server.start() loop.run_forever() except KeyboardInterrupt: vim_server.stop() web_server.stop() if __name__ == '__main__': options.parse_command_line() main()
console.log(elm.textContent) } } ''' mount_point = Div(parent=doc.body, class_='container') mount_point.appendChild(H2('LiveMark is running...')) app = get_app(doc) app.add_static_path('static', static_dir) for _d in _user_static_dirs: app.add_static_path(_d, _d) web_server = start_server(app, port=options.config.browser_port) loop = asyncio.get_event_loop() vim_server = Server(port=options.config.vim_port, loop=loop, doc=doc, mount_point=mount_point) browser = webbrowser.get(options.config.browser) browser.open('http://localhost:{}'.format(options.config.browser_port)) try: vim_server.start() loop.run_forever() except KeyboardInterrupt: vim_server.stop() web_server.stop() if __name__ == '__main__': options.parse_command_line() main()
def test_loglevel(self, level_name, level): sys.argv.extend(['--logging', level_name]) parse_command_line() logger = logging.getLogger('wdom') self.assertEqual(logger.getEffectiveLevel(), level) reset_options()
def test_debug_without_logging(self): sys.argv.extend(['--debug']) parse_command_line() logger = logging.getLogger('wdom') self.assertEqual(logger.getEffectiveLevel(), logging.DEBUG)