Python logging.disable() Examples
The following are 30
code examples of logging.disable().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
logging
, or try the search function
.
Example #1
Source File: end_to_end.py From ripozo with GNU General Public License v2.0 | 6 votes |
def setUp(self): logging.disable('DEBUG') class MyManager(InMemoryManager): _fields = ('id', 'first', 'second',) _field_validators = { 'first': fields.IntegerField('first', required=True), 'second': fields.IntegerField('second', required=True) } class MyClass(CRUDL): resource_name = 'myresource' manager = MyManager() self.resource_class = MyClass self.manager = MyClass.manager for i in six.moves.range(100): self.manager.objects[i] = dict(id=i, first=1, second=2) self.dispatcher = FakeDispatcher() self.dispatcher.register_adapters(SirenAdapter, HalAdapter, BoringJSONAdapter)
Example #2
Source File: test_soup.py From locality-sensitive-hashing with MIT License | 6 votes |
def test_ascii_in_unicode_out(self): # ASCII input is converted to Unicode. The original_encoding # attribute is set to 'utf-8', a superset of ASCII. chardet = bs4.dammit.chardet_dammit logging.disable(logging.WARNING) try: def noop(str): return None # Disable chardet, which will realize that the ASCII is ASCII. bs4.dammit.chardet_dammit = noop ascii = b"<foo>a</foo>" soup_from_ascii = self.soup(ascii) unicode_output = soup_from_ascii.decode() self.assertTrue(isinstance(unicode_output, unicode)) self.assertEqual(unicode_output, self.document_for(ascii.decode())) self.assertEqual(soup_from_ascii.original_encoding.lower(), "utf-8") finally: logging.disable(logging.NOTSET) bs4.dammit.chardet_dammit = chardet
Example #3
Source File: test_trade.py From flumine with MIT License | 6 votes |
def setUp(self) -> None: logging.disable(logging.CRITICAL) self.mock_strategy = mock.Mock() self.mock_fill_kill = mock.Mock() self.mock_offset = mock.Mock() self.mock_green = mock.Mock() self.mock_stop = mock.Mock() self.notes = collections.OrderedDict({"trigger": 123}) self.trade = Trade( "1.234", 567, 1.0, self.mock_strategy, self.notes, self.mock_fill_kill, self.mock_offset, self.mock_green, self.mock_stop, )
Example #4
Source File: test_soup.py From ServerlessCrawler-VancouverRealState with MIT License | 6 votes |
def test_ascii_in_unicode_out(self): # ASCII input is converted to Unicode. The original_encoding # attribute is set to 'utf-8', a superset of ASCII. chardet = bs4.dammit.chardet_dammit logging.disable(logging.WARNING) try: def noop(str): return None # Disable chardet, which will realize that the ASCII is ASCII. bs4.dammit.chardet_dammit = noop ascii = b"<foo>a</foo>" soup_from_ascii = self.soup(ascii) unicode_output = soup_from_ascii.decode() self.assertTrue(isinstance(unicode_output, unicode)) self.assertEqual(unicode_output, self.document_for(ascii.decode())) self.assertEqual(soup_from_ascii.original_encoding.lower(), "utf-8") finally: logging.disable(logging.NOTSET) bs4.dammit.chardet_dammit = chardet
Example #5
Source File: tests_middleware.py From koku with GNU Affero General Public License v3.0 | 6 votes |
def test_race_condition_user_caching(self): """Test case for caching where another request may create the user in a race condition.""" mock_request = self.request middleware = IdentityHeaderMiddleware() self.assertEquals(MD.USER_CACHE.maxsize, 5) # Confirm that the size of the user cache has changed self.assertEquals(MD.USER_CACHE.currsize, 0) # Confirm that the user cache is empty middleware.process_request(mock_request) self.assertEquals(MD.USER_CACHE.currsize, 1) self.assertTrue(hasattr(mock_request, "user")) customer = Customer.objects.get(account_id=self.customer.account_id) self.assertIsNotNone(customer) user = User.objects.get(username=self.user_data["username"]) self.assertEquals(MD.USER_CACHE.currsize, 1) self.assertIsNotNone(user) IdentityHeaderMiddleware.create_user( username=self.user_data["username"], # pylint: disable=W0212 email=self.user_data["email"], customer=customer, request=mock_request, ) self.assertEquals(MD.USER_CACHE.currsize, 1)
Example #6
Source File: test_soup.py From ServerlessCrawler-VancouverRealState with MIT License | 6 votes |
def test_ascii_in_unicode_out(self): # ASCII input is converted to Unicode. The original_encoding # attribute is set to 'utf-8', a superset of ASCII. chardet = bs4.dammit.chardet_dammit logging.disable(logging.WARNING) try: def noop(str): return None # Disable chardet, which will realize that the ASCII is ASCII. bs4.dammit.chardet_dammit = noop ascii = b"<foo>a</foo>" soup_from_ascii = self.soup(ascii) unicode_output = soup_from_ascii.decode() self.assertTrue(isinstance(unicode_output, unicode)) self.assertEqual(unicode_output, self.document_for(ascii.decode())) self.assertEqual(soup_from_ascii.original_encoding.lower(), "utf-8") finally: logging.disable(logging.NOTSET) bs4.dammit.chardet_dammit = chardet
Example #7
Source File: test_luns.py From lrbd with GNU Lesser General Public License v2.1 | 6 votes |
def test_cmd_for_rbd(self): Runtime.config['backstore'] = "rbd" class mock_Luns(Luns): def _find(self): pass class mock_LunAssignment(object): def assign(self, target, tpg, image, lun): pass def assigned(self, target, image): pass logging.disable(logging.DEBUG) _la = mock_LunAssignment() self.l = mock_Luns(_la) print self.l.unassigned assert self.l.unassigned == [ ['targetcli', '/iscsi/iqn.xyz/tpg1/luns', 'create', '/backstores/rbd/rbd-archive'] ]
Example #8
Source File: test_soup.py From ServerlessCrawler-VancouverRealState with MIT License | 6 votes |
def test_ascii_in_unicode_out(self): # ASCII input is converted to Unicode. The original_encoding # attribute is set to 'utf-8', a superset of ASCII. chardet = bs4.dammit.chardet_dammit logging.disable(logging.WARNING) try: def noop(str): return None # Disable chardet, which will realize that the ASCII is ASCII. bs4.dammit.chardet_dammit = noop ascii = b"<foo>a</foo>" soup_from_ascii = self.soup(ascii) unicode_output = soup_from_ascii.decode() self.assertTrue(isinstance(unicode_output, unicode)) self.assertEqual(unicode_output, self.document_for(ascii.decode())) self.assertEqual(soup_from_ascii.original_encoding.lower(), "utf-8") finally: logging.disable(logging.NOTSET) bs4.dammit.chardet_dammit = chardet
Example #9
Source File: test_soup.py From pledgeservice with Apache License 2.0 | 6 votes |
def test_ascii_in_unicode_out(self): # ASCII input is converted to Unicode. The original_encoding # attribute is set to 'utf-8', a superset of ASCII. chardet = bs4.dammit.chardet_dammit logging.disable(logging.WARNING) try: def noop(str): return None # Disable chardet, which will realize that the ASCII is ASCII. bs4.dammit.chardet_dammit = noop ascii = b"<foo>a</foo>" soup_from_ascii = self.soup(ascii) unicode_output = soup_from_ascii.decode() self.assertTrue(isinstance(unicode_output, unicode)) self.assertEqual(unicode_output, self.document_for(ascii.decode())) self.assertEqual(soup_from_ascii.original_encoding.lower(), "utf-8") finally: logging.disable(logging.NOTSET) bs4.dammit.chardet_dammit = chardet
Example #10
Source File: restmixins.py From ripozo with GNU General Public License v2.0 | 6 votes |
def setUp(self): logging.disable('DEBUG') class MyManager(InMemoryManager): _fields = ('id', 'first', 'second',) _field_validators = { 'first': fields.IntegerField('first', required=True), 'second': fields.IntegerField('second', required=True) } class MyClass(CRUDL): manager = MyManager() resource_name = 'myresource' self.resource_class = MyClass self.manager = MyClass.manager
Example #11
Source File: adapters.py From ripozo with GNU General Public License v2.0 | 6 votes |
def setUp(self): logging.disable('DEBUG') class MyManager(InMemoryManager): _fields = ('id', 'first', 'second',) _field_validators = { 'first': fields.IntegerField('first', required=True), 'second': fields.IntegerField('second', required=True) } class MyClass(CRUDL): resource_name = 'myresource' manager = MyManager() self.resource_class = MyClass self.manager = MyClass.manager for i in six.moves.range(100): self.manager.objects[i] = dict(id=i, first=1, second=2) self.resource = MyClass.retrieve_list(RequestContainer())
Example #12
Source File: test_azure_report_processor.py From koku with GNU Affero General Public License v3.0 | 6 votes |
def test_azure_process(self): """Test the processing of an uncompressed Azure file.""" counts = {} report_db = self.accessor report_schema = report_db.report_schema for table_name in self.report_tables: table = getattr(report_schema, table_name) with schema_context(self.schema): count = table.objects.count() counts[table_name] = count logging.disable(logging.NOTSET) # We are currently disabling all logging below CRITICAL in masu/__init__.py with self.assertLogs("masu.processor.azure.azure_report_processor", level="INFO") as logger: self.processor.process() self.assertIn("INFO:masu.processor.azure.azure_report_processor", logger.output[0]) self.assertIn("costreport_a243c6f2-199f-4074-9a2c-40e671cf1584.csv", logger.output[0]) for table_name in self.report_tables: table = getattr(report_schema, table_name) with schema_context(self.schema): count = table.objects.count() self.assertTrue(count > counts[table_name]) self.assertFalse(os.path.exists(self.test_report))
Example #13
Source File: test_tasks.py From koku with GNU Affero General Public License v3.0 | 6 votes |
def test_disk_status_logging(self, fake_downloader): """Test task for logging when temp directory exists.""" logging.disable(logging.NOTSET) os.makedirs(Config.TMP_DIR, exist_ok=True) account = fake_arn(service="iam", generate_account_id=True) expected = "Available disk space" with self.assertLogs("masu.processor._tasks.download", level="INFO") as logger: _get_report_files( Mock(), customer_name=self.fake.word(), authentication=account, provider_type=Provider.PROVIDER_AWS, report_month=DateHelper().today, provider_uuid=self.aws_provider_uuid, billing_source=self.fake.word(), cache_key=self.fake.word(), ) statement_found = False for log in logger.output: if expected in log: statement_found = True self.assertTrue(statement_found) shutil.rmtree(Config.TMP_DIR, ignore_errors=True)
Example #14
Source File: test_tasks.py From koku with GNU Affero General Public License v3.0 | 6 votes |
def test_disk_status_logging_no_dir(self, fake_downloader): """Test task for logging when temp directory does not exist.""" logging.disable(logging.NOTSET) Config.PVC_DIR = "/this/path/does/not/exist" account = fake_arn(service="iam", generate_account_id=True) expected = "Unable to find" + f" available disk space. {Config.PVC_DIR} does not exist" with self.assertLogs("masu.processor._tasks.download", level="INFO") as logger: _get_report_files( Mock(), customer_name=self.fake.word(), authentication=account, provider_type=Provider.PROVIDER_AWS, report_month=DateHelper().today, provider_uuid=self.aws_provider_uuid, billing_source=self.fake.word(), cache_key=self.fake.word(), ) statement_found = False for log in logger.output: if expected in log: statement_found = True self.assertTrue(statement_found)
Example #15
Source File: test_expired_data_remover.py From koku with GNU Affero General Public License v3.0 | 5 votes |
def test_simulate_delete_expired_cost_usage_report_manifest_by_provider_uuid(self): """ Test simulating the deletion of expired CostUsageReportManifests. using remove(provider_uuid) """ remover = ExpiredDataRemover(self.schema, Provider.PROVIDER_AWS) expiration_date = remover._calculate_expiration_date() day_before_cutoff = expiration_date - relativedelta.relativedelta(days=1) day_before_cutoff_data = { "assembly_id": uuid4(), "manifest_creation_datetime": None, "manifest_updated_datetime": None, "billing_period_start_datetime": day_before_cutoff, "num_processed_files": 1, "num_total_files": 1, "provider_id": self.aws_provider_uuid, } CostUsageReportManifest(**day_before_cutoff_data).save() count_records = CostUsageReportManifest.objects.count() with self.assertLogs(logger="masu.processor.expired_data_remover", level="INFO") as cm: logging.disable(logging.NOTSET) remover.remove(simulate=True, provider_uuid=self.aws_provider_uuid) expected_log_message = "Removed CostUsageReportManifest" # Check if the log message exists in the log output: self.assertTrue( any(match is not None for match in [re.search(expected_log_message, line) for line in cm.output]), "Expected to see log message: " + expected_log_message + "in the list of log messages" + " but the list of log messages was instead : " + str(cm.output), ) # Re-enable log suppression logging.disable(logging.CRITICAL) self.assertEqual(count_records, CostUsageReportManifest.objects.count())
Example #16
Source File: tests_status.py From koku with GNU Affero General Public License v3.0 | 5 votes |
def setUpClass(cls): """Test Class setup.""" # remove filters on logging logging.disable(logging.NOTSET) cls.status_info = Status()
Example #17
Source File: test_soup.py From locality-sensitive-hashing with MIT License | 5 votes |
def test_last_ditch_entity_replacement(self): # This is a UTF-8 document that contains bytestrings # completely incompatible with UTF-8 (ie. encoded with some other # encoding). # # Since there is no consistent encoding for the document, # Unicode, Dammit will eventually encode the document as UTF-8 # and encode the incompatible characters as REPLACEMENT # CHARACTER. # # If chardet is installed, it will detect that the document # can be converted into ISO-8859-1 without errors. This happens # to be the wrong encoding, but it is a consistent encoding, so the # code we're testing here won't run. # # So we temporarily disable chardet if it's present. doc = b"""\357\273\277<?xml version="1.0" encoding="UTF-8"?> <html><b>\330\250\330\252\330\261</b> <i>\310\322\321\220\312\321\355\344</i></html>""" chardet = bs4.dammit.chardet_dammit logging.disable(logging.WARNING) try: def noop(str): return None bs4.dammit.chardet_dammit = noop dammit = UnicodeDammit(doc) self.assertEqual(True, dammit.contains_replacement_characters) self.assertTrue(u"\ufffd" in dammit.unicode_markup) soup = BeautifulSoup(doc, "html.parser") self.assertTrue(soup.contains_replacement_characters) finally: logging.disable(logging.NOTSET) bs4.dammit.chardet_dammit = chardet
Example #18
Source File: tests_status.py From koku with GNU Affero General Public License v3.0 | 5 votes |
def tearDownClass(cls): """Test Class teardown.""" # restore filters on logging logging.disable(logging.CRITICAL)
Example #19
Source File: test_kafka_source_manager.py From koku with GNU Affero General Public License v3.0 | 5 votes |
def test_destroy_provider_exception(self): """Test to destroy a provider with a connection error.""" client = ProviderBuilder(auth_header=Config.SOURCES_FAKE_HEADER) source_uuid = faker.uuid4() with patch.object(ProviderAccessor, "cost_usage_source_ready", returns=True): provider = client.create_provider( self.name, self.provider_type, self.authentication, self.billing_source, source_uuid ) self.assertEqual(provider.name, self.name) self.assertEqual(str(provider.uuid), source_uuid) logging.disable(logging.NOTSET) with self.assertLogs(logger="api.provider.provider_builder", level=logging.INFO): client.destroy_provider(faker.uuid4())
Example #20
Source File: test_expired_data_remover.py From koku with GNU Affero General Public License v3.0 | 5 votes |
def test_simulate_delete_expired_cost_usage_report_manifest(self): """ Test that expired CostUsageReportManifest is not removed during simulation. Test that the number of records that would have been deleted is logged. """ remover = ExpiredDataRemover(self.schema, Provider.PROVIDER_AWS) expiration_date = remover._calculate_expiration_date() day_before_cutoff = expiration_date - relativedelta.relativedelta(days=1) day_before_cutoff_data = { "assembly_id": uuid4(), "manifest_creation_datetime": None, "manifest_updated_datetime": None, "billing_period_start_datetime": day_before_cutoff, "num_processed_files": 1, "num_total_files": 1, "provider_id": self.aws_provider_uuid, } CostUsageReportManifest(**day_before_cutoff_data).save() with self.assertLogs(logger="masu.processor.expired_data_remover", level="INFO") as cm: logging.disable(logging.NOTSET) remover.remove(simulate=True) expected_log_message = "Removed CostUsageReportManifest" # Check if the log message exists in the log output: self.assertTrue( any(match is not None for match in [re.search(expected_log_message, line) for line in cm.output]), "Expected to see log message: " + expected_log_message + "in the list of log messages" + " but the list of log messages was instead : " + str(cm.output), ) # Re-enable log suppression logging.disable(logging.CRITICAL)
Example #21
Source File: tests_metrics.py From koku with GNU Affero General Public License v3.0 | 5 votes |
def test_db_is_not_connected(self, mock_connection): """Test that db is not connected, log at ERROR level and counter increments.""" mock_connection.cursor.side_effect = OperationalError("test exception") logging.disable(logging.NOTSET) before = REGISTRY.get_sample_value("db_connection_errors_total") self.assertIsNotNone(before) with self.assertLogs(logger="koku.metrics", level=logging.ERROR): DatabaseStatus().connection_check() after = REGISTRY.get_sample_value("db_connection_errors_total") self.assertIsNotNone(after) self.assertEqual(1, after - before)
Example #22
Source File: namespace.py From agentless-system-crawler with Apache License 2.0 | 5 votes |
def detach(self): try: # Re-attach to the process original namespaces. attach_to_process_namespaces(self.host_ns_fds, self.namespaces) # We are now in host context os.chdir(self.host_cwd) close_process_namespaces(self.container_ns_fds, self.namespaces) close_process_namespaces(self.host_ns_fds, self.namespaces) finally: # Enable logging again logging.disable(logging.NOTSET)
Example #23
Source File: namespace.py From agentless-system-crawler with Apache License 2.0 | 5 votes |
def attach(self): # Disable logging just to be sure log rotation does not happen in # the container. logging.disable(logging.CRITICAL) attach_to_process_namespaces(self.container_ns_fds, self.namespaces)
Example #24
Source File: test_binaries.py From fairseq with MIT License | 5 votes |
def setUp(self): logging.disable(logging.CRITICAL)
Example #25
Source File: test_binaries.py From fairseq with MIT License | 5 votes |
def tearDown(self): logging.disable(logging.NOTSET)
Example #26
Source File: test_binaries.py From fairseq with MIT License | 5 votes |
def setUp(self): logging.disable(logging.CRITICAL)
Example #27
Source File: test_binaries.py From fairseq with MIT License | 5 votes |
def tearDown(self): logging.disable(logging.NOTSET)
Example #28
Source File: test_binaries.py From fairseq with MIT License | 5 votes |
def setUp(self): logging.disable(logging.CRITICAL)
Example #29
Source File: test_binaries.py From fairseq with MIT License | 5 votes |
def setUp(self): logging.disable(logging.CRITICAL)
Example #30
Source File: test_binaries.py From fairseq with MIT License | 5 votes |
def tearDown(self): logging.disable(logging.NOTSET)