This file contains hidden or 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
cd ~ | |
sudo apt-get update | |
sudo apt-get install openjdk-7-jre -y | |
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.6.tar.gz -O elasticsearch.tar.gz | |
tar -xf elasticsearch.tar.gz | |
rm elasticsearch.tar.gz | |
sudo mv elasticsearch-* elasticsearch | |
sudo mv elasticsearch /usr/local/share |
This file contains hidden or 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 Old(): | |
... pass | |
... | |
>>> class New(object): | |
... pass | |
... | |
>>> type(Old()) | |
<type 'instance'> | |
>>> type(New()) | |
<class '__main__.New'> |
This file contains hidden or 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 IdentifierList(list): | |
... def by_namespace(self): | |
... return None | |
... | |
>>> class Locality(): | |
... @property | |
... def identifiers(self): | |
... return IdentifierList(self._identifiers) | |
... @identifiers.setter | |
... def identifiers(self, value): |
This file contains hidden or 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
from molly.apps.feeds.events import IndexView, Feed | |
from unittest import TestCase | |
class TestMocking(TestCase): | |
def test_mock_count(self): | |
Feed.objects = Mock() | |
feeds = [Feed(url='http://foo.bar'), Feed(url='http://bar.baz')] | |
mock_queryset = Mock(return_value=feeds) | |
mock_queryset.count.return_value = 42 | |
Feed.objects.all = mock_queryset |
NewerOlder