Skip to content

Instantly share code, notes, and snippets.

View ramiroluz's full-sized avatar

Ramiro Batista da Luz ramiroluz

  • Câmara Municipal de Curitiba
  • Câmara Municipal de Curitiba
  • X @ramiroluz
View GitHub Profile
# Salvar arvore html da página de vídeos pythonbrasil no arquivo /tmp/dom.html
# http://www.youtube.com/user/pythonbrazil/videos?view=0&sort=dd&live_view=500&flow=list
# BeautifulSoup versão 3.2.1, o método para buscar a classe mudou na versão 4.
s = file('/tmp/dom.html').read()
from BeautifulSoup import BeautifulSoup as BS
soup = BS(s)
soup.findAll('li', { "class" : "yt-lockup clearfix channels-browse-content-list-item yt-lockup-video yt-lockup-tile vve-check context-data-item" })
items = soup.findAll('li', { "class" : "yt-lockup clearfix channels-browse-content-list-item yt-lockup-video yt-lockup-tile vve-check context-data-item" })
l = [x.attrMap['data-context-item-title'] for x in items]
@ramiroluz
ramiroluz / gist:7220492
Created October 29, 2013 18:54
csslint error.
$ cat codeanalysis.cfg
[buildout]
extends =
buildout.cfg
auto-checkout = plone.recipe.codeanalysis
parts += code-analysis
[sources]
plone.recipe.codeanalysis = git https://github.com/plone/plone.recipe.codeanalysis.git
@ramiroluz
ramiroluz / gist:7153081
Created October 25, 2013 11:15
CSSLint usage example.
# csslint incorrect.css correct.css
csslint: There are 2 problems in incorrect.css.
incorrect.css
1: error at line 2, col 1
Unexpected token '{' at line 2, col 1.
{}
Patching and mocking Plone unittests with using mock
----------------------------------------------------
The python mock module was created by Michael Foord and it has been integrated in the unittest module since python version 3.3. It's license is BSD as it is possible to see in the official `homepage of the project`_.
.. _homepage of the project: http://www.voidspace.org.uk/python/mock/index.html
It allows you to replace parts of your system under test with mock objects and make assertions about how they have been used.
You can use it to replace methods or properties, as it will be shown in the following examples.
Patching and mocking Plone unittests with using mock
----------------------------------------------------
The python mock module was created by Michael Foord and it has been integrated in the unittest module since python version 3.3. It's license is BSD as it is possible to see in the official `homepage of the project`_.
.. _homepage of the project: http://www.voidspace.org.uk/python/mock/index.html
It allows you to replace parts of your system under test with mock objects and make assertions about how they have been used.
You can use it to replace methods or properties, as it will be shown in the following examples.