Python é uma das mais poderosas ferramentas de prototipação e analise de hipóteses. Mas o que muitos não sabem, é que também podemos ter produtos completos em produção totalmente baseados em Python. Ai vem a pergunta, como garantir a qualidade e eficiência do meu projeto em Python ???
Venha descobrir como aplicar e garantir a qualidade dos seus projetos através de testes eficientes, checagem de cobertura de código, analise estática, índice de mantenabilidade dentre outras técnicas.
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Qualidade levada a sério em Python - Emilio Simoni
1. simple is better than complex
The Zen of Python (import this)
Qualidade levada a sério em Python
2. • Master Coaching Trainer
• Pesquisador de segurança sênior
• Programador C/C++ e Python
• Data Scientist
• Viciado em competições de ML
• Coordenador equipe ameaças PSafe
3. 5° software mais baixado
Maior empresa mobile LA
200 mil downloads/dia
23. import unittest
from foobarbaz import Foo # code from module you're testing
class SimpleTestCase(unittest.TestCase):
def setUp(self):
"""Call before every test case.""“
self.foo = Foo()
self.file = open( "blah", "r" )
def tearDown(self):
"""Call after every test case.""“
self.file.close()
def test_get_client_name__with_invalid__params_must_return_False (self):
"""Test case 1. note that all test method names must begin with 'test.'""“
self.assertEqual(foo.get_client_name(None) , False)
Test Suite
26. Teste se torna o primeiro cliente do seu código
Somente o codigo necessario é criado
Erros são identificados mais rapidamente
Ganho de produtividade
Códigos entregues realmente prontos
Facilita depuração
34. Performance Tests@profile
def primes(n):
if n==2:
return [2]
elif n<2:
return []
s=range(3,n+1,2)
mroot = n ** 0.5
half=(n+1)/2-1
i=0
m=3
while m <= mroot:
if s[i]:
j=(m*m-3)/2
s[j]=0
while j<half:
s[j]=0
j+=m
i=i+1
m=2*i+3
return [2]+[x for x in s if x]
primes(100)
pip install line_profiler
kernprof -l –v primes.py
35. Performance Tests
Line # Hits Time Per Hit % Time Line Contents
==============================================================
2 @profile
3 def primes(n):
4 1 2 2.0 1.1 if n==2:
5 return [2]
6 1 1 1.0 0.5 elif n<2:
7 return []
8 1 4 4.0 2.1 s=range(3,n+1,2)
9 1 10 10.0 5.3 mroot = n ** 0.5
10 1 2 2.0 1.1 half=(n+1)/2-1
11 1 1 1.0 0.5 i=0
12 1 1 1.0 0.5 m=3
13 5 7 1.4 3.7 while m <= mroot:
14 4 4 1.0 2.1 if s[i]:
15 3 4 1.3 2.1 j=(m*m-3)/2
16 3 4 1.3 2.1 s[j]=0
17 31 31 1.0 16.3 while j<half:
18 28 28 1.0 14.7 s[j]=0
19 28 29 1.0 15.3 j+=m
20 4 4 1.0 2.1 i=i+1
21 4 4 1.0 2.1 m=2*i+3
22 50 54 1.1 28.4 return [2]+[x for x in s if x]
48. Documentação
DocStrings
Documentação simples e clara, não deve conter detalhes da implementação
Documentação ruim é pior do que não documentado
Sumarizar o comportamento da função
Argumentos, retornos, exceções disparadas e restrições.
Não documentar o obvio
52. Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!