This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Add this fixture to a file containing a test, or to your global `conftest.py`, to turn warnings into errors. | |
This way the test will break at the warning point, and your traceback will likely contain all functions or methods | |
responsible for creating the conditions for the warning being raised. | |
For instance, in the case of a `SettingWithCopyWarning` from pandas, the function that tries to mutate a dataframe | |
view/slice might not be the function that created the dataframe view/slice in the first place, but that function | |
is probably in the stack somewhere. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on the description found at https://dicasdeprogramacao.com.br/algoritmo-para-validar-cpf/ | |
def get_cpf_mod_11_digit(digits): | |
weights = range(len(digits) + 1, 1, -1) | |
weighted = [digit * weight for digit, weight in zip(digits, weights)] | |
weighted_sum = sum(weighted) | |
extra_digit = weighted_sum * 10 % 11 % 10 | |
return extra_digit | |
def int_to_cpf_with_digits(num): | |
assert num < 1000000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import signal | |
def may_debug_handler(sig, frame): | |
# allow double CTRL+C to really break interrupt: | |
signal.signal(signal.SIGINT, signal.default_int_handler) | |
c = input('(d)ebug? (i)nterrupt? ') | |
print 'got:', c | |
if c == 'd': | |
breakpoint() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Paste this in ipython_odoo use it like this: | |
# r.res.users(1, 2, 3,) | |
# | |
# the "res.users(1, 2, 3,)" above is the printable representation of a recordset, sometimes output in logging. | |
class Resolver(object): | |
_completables = None | |
def __init__(self, env, name_parts=()): | |
self._env = env | |
self._name_parts = name_parts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This file can be used to demonstrate that the exit status of the process | |
that is run by a os.exec*() call will be taken as the exit status of the | |
original process, as can be expected from the fact that os.exec() completely | |
replaces the original process. | |
Use it like this on bash: | |
python test_exit.py die 2 ; echo $? | |
python test_exit.py sub 2 ; echo $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[buildout] | |
parts = odoo | |
find-links = http://download.gna.org/pychart/ | |
[odoo] | |
version = git http://github.com/odoo/odoo.git odoo 8.0 depth=1 | |
recipe = anybox.recipe.odoo:server | |
eggs = | |
nose | |
ipython |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Robot library helpers for debugging | |
''' | |
import sys | |
import pdb | |
import IPython | |