Skip to content

Instantly share code, notes, and snippets.

View Eduard-gan's full-sized avatar

Eduard Gan Eduard-gan

  • Self employed
  • Russian federation
View GitHub Profile
pip install mutmut
mutmut run --runner 'python -m pytest -x tests/test_quiz.py' --paths-to-mutate business_logic/credit_history_quiz.py
mutmut results # Shows munants IDs (X here)
mutmut show X # Shows diff metant/original
mutmut apply X # Applies change from mutant to file
То stop certain line from mutation (Annoying on log lines) apply whitelisting comment on it: # pragma: no mutate
@Eduard-gan
Eduard-gan / gist:f769c239d0b4021d55f9b065bebbba11
Last active August 10, 2020 17:42
Python: Exception class that brings some structured data to caller
import logging
class InsufficientFunds(PaymentSystemError):
requested_amount: float = None
direction: FinDirection = None
account_balance: float = None
def __init__(self, *args, direction=None, requested_amount=None, account_balance=None, **kwargs):
self.direction = direction
pg_dump -U postgres -Fc mfo > mfo.sql
docker cp postgres:/mfo.sql mfo.sql
docker cp mfo.sql postgres:/mfo.sql
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'mfo' AND pid <> pg_backend_pid();
drop database mfo;
create database mfo;
pg_restore -U postgres -d mfo --clean --create mfo.sql
@Eduard-gan
Eduard-gan / test.py
Created December 29, 2021 10:55
Async structured logging with loguru
import asyncio
from aiologger import Logger
from loguru import logger
def async_logging(msg):
aio_logger = Logger.with_default_handlers(name='my-logger')
method = getattr(aio_logger, msg.record['level'].name.lower())
method(f"AIO LOGGING: {msg}")