Best Python code snippet using avocado_python
logger_tests.py
Source:logger_tests.py
...16 logger_one = LogManager.get_logger('one')17 self.assertEqual(len(LogManager.loggers), 1, 'Incorrect number of loggers')18 LogManager.get_logger('two')19 self.assertEqual(len(LogManager.loggers), 2, 'Incorrect number of loggers')20 logger_one.start_logging()21 query = Query().from_table(Account)22 query.select()23 self.assertEqual(logger_one.count(), 1, 'Incorrect number of queries')24 LogManager.disable_logging()25 query.select()26 self.assertEqual(logger_one.count(), 1, 'Incorrect number of queries')27 LogManager.enable_logging()28 query.select()29 self.assertEqual(logger_one.count(), 2, 'Incorrect number of queries')30@override_settings(DEBUG=True)31class LoggerTest(QuerybuilderTestCase):32 """33 Includes functions to test the Logger34 """35 def setUp(self):36 super(LoggerTest, self).setUp()37 LogManager.reset()38 def test_init(self):39 """40 Tests the init method41 """42 logger = Logger()43 self.assertEqual('default', logger.name)44 self.assertIsNone(logger.query_index)45 self.assertEqual(0, len(logger.queries))46 self.assertEqual(1, len(LogManager.loggers))47 logger = Logger('custom_name')48 self.assertEqual('custom_name', logger.name)49 self.assertEqual(2, len(LogManager.loggers))50 def test_start_logging(self):51 """52 Verifies that the query index gets updated53 """54 logger = Logger()55 query = Query().from_table(Account)56 query.select()57 query.select()58 logger.start_logging()59 self.assertEqual(logger.query_index, len(connection.queries))60 def test_count(self):61 """62 Verifies that the correct number of queries is returned63 """64 logger = Logger()65 logger.start_logging()66 query = Query().from_table(Account)67 query.select()68 query.select()69 self.assertEqual(2, logger.count())70 query.select()71 self.assertEqual(3, logger.count())72 def test_stop_logging(self):73 """74 Verifies that the logger stops caring about queries75 """76 logger = Logger()77 logger.start_logging()78 query = Query().from_table(Account)79 query.select()80 query.select()81 self.assertEqual(2, logger.count())82 logger.stop_logging()83 query.select()84 query.select()85 self.assertEqual(2, logger.count())86 logger.start_logging()87 query.select()88 self.assertEqual(3, logger.count())89 def test_get_log(self):90 """91 Verifies that queries get returned92 """93 pass94 def test_update_log(self):95 """96 Verifies that the log gets updated properly97 """98 pass99 def test_logger(self):100 logger_one = Logger('one')101 logger_two = Logger('two')102 logger_one.start_logging()103 query = Query().from_table(Account)104 query.select()105 self.assertEqual(logger_one.count(), 1, 'Incorrect number of queries')106 query.select()107 logger_two.start_logging()108 query.select()109 logger_one.stop_logging()110 query.select()111 self.assertEqual(logger_one.count(), 3, 'Incorrect number of queries')112 self.assertEqual(logger_two.count(), 2, 'Incorrect number of queries')113 query.select()114 logger_one.start_logging()115 query.select()116 self.assertEqual(logger_one.count(), 4, 'Incorrect number of queries')117 self.assertEqual(logger_two.count(), 4, 'Incorrect number of queries')118 query.select()119 logger_two.clear_log()120 query.select()121 self.assertEqual(logger_one.count(), 6, 'Incorrect number of queries')122 self.assertEqual(logger_two.count(), 1, 'Incorrect number of queries')123 def test_clear_log(self):124 """125 Makes sure queries are cleared126 """127 logger_one = Logger('one')128 logger_one.start_logging()129 query = Query().from_table(Account)130 # run a query and update the logger's query list131 query.select()132 logger_one.update_log()133 # there should be one query134 self.assertEqual(logger_one.count(), 1)135 # increment the connection query count136 query.select()137 # clear the log138 logger_one.clear_log()139 # make sure no queries140 self.assertEqual(0, len(logger_one.queries))141 def test_clear_log_no_index(self):142 """...
test_forestry.py
Source:test_forestry.py
...28 self.assertIsNone(graham.tree)29 self.assertEqual(boards, brds) 30 31if __name__ == "__main__":32 start_logging(level="error") # add start_logging and level...
test_start_logging.py
Source:test_start_logging.py
1import logging2from golem_task_api.apputils import start_logging3class TestLogger:4 def test_from_arg_defaults(self):5 start_logging.from_arg()6 assert logging.getLogger().getEffectiveLevel() \7 == start_logging.DEFAULT_LEVEL8 def test_from_arg_debug_arg(self):9 start_logging.from_arg(log_level_arg='DEBUG')...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!