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
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. |
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
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. |
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
# 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. | |
{} |
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
$ 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 |
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
# 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] |
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
class ContatoAgrupadoPorGrupoFilterSet(FilterSet): | |
search = MethodFilter() | |
municipio = MethodModelChoiceFilter( | |
required=False, | |
queryset=Municipio.objects.all()) | |
grupo = MethodModelChoiceFilter( | |
required=False, | |
queryset=GrupoDeContatos.objects.all()) |
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
====================================================================== | |
FAIL: test_docstrings (tests.modules.test_math.MathTests) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "/home/ramiro/python/pybee/batavia-dev/batavia/tests/modules/test_math.py", line 165, in test_docstrings | |
""") | |
File "/home/ramiro/python/pybee/batavia-dev/batavia/tests/utils.py", line 504, in assertCodeExecution | |
self.assertEqual(js_out, py_out, context) | |
AssertionError: 'acos[76 chars] the inverse hyperbolic cosine of x.\nasin(x)\[3067 chars]d.\n' != 'acos[76 chars] the hyperbolic arc cosine (measured in radian[3121 chars]d.\n' | |
acos(x) |
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
# -*- coding: utf-8 -*- | |
from zope.component import queryUtility | |
from plone.i18n.normalizer.interfaces import IIDNormalizer | |
from plone.dexterity.fti import DexterityFTI | |
from interlegis.portalmodelo.ombudsman.testing import create_ombudsoffice | |
from interlegis.portalmodelo.ombudsman.testing import INTEGRATION_TESTING | |
from interlegis.portalmodelo.ombudsman.browser.claims_by_tag import json_claims_by_tag | |
from interlegis.portalmodelo.ombudsman.browser.claims_by_tag import get_claim_tag | |
from interlegis.portalmodelo.ombudsman.browser.claims_by_tag import count_claims_by_tag | |
from interlegis.portalmodelo.ombudsman.browser.claims_by_tag import csv_claims_by_tag |
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
diff --git a/src/interlegis/portalmodelo/ombudsman/content/claim.py b/src/interlegis/portalmodelo/ombudsman/content/claim.py | |
index 3278b84..71936a9 100644 | |
--- a/src/interlegis/portalmodelo/ombudsman/content/claim.py | |
+++ b/src/interlegis/portalmodelo/ombudsman/content/claim.py | |
@@ -1,10 +1,12 @@ | |
# -*- coding: utf-8 -*- | |
from interlegis.portalmodelo.ombudsman.interfaces import IClaim | |
-from five import grok | |
+# from five import grok |
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
# https://github.com/philchalmers/mirtCAT/blob/master/R/extract.mirtCAT.R | |
set.seed(1234) | |
nitems <- 25 | |
itemnames <- paste0('Item.', 1:nitems) | |
a <- matrix(rlnorm(nitems, .2, .3)) | |
d <- matrix(rnorm(nitems)) | |
dat <- simdata(a, d, 500, itemtype = 'dich') | |
colnames(dat) <- itemnames | |
mod <- mirt(dat, 1, verbose = FALSE, TOL = .01) |
OlderNewer