Index ¦ Archives ¦ Atom > Author: Amit Saha

Mock objects and non-existent attributes/methods in Python

Updated: Fixed typo in the last paragraph.

Today, I was curious to see this behavior of Mock() objects when using mock:

>>> from mock import Mock
>>> m = Mock()
>>> m.i_dont_exist
<Mock name='mock.i_dont_exist' id='139841609578768'>
>>> m.i_dont_exist()
<Mock name='mock.i_dont_exist()' id='139841609106896'>

The above is expected, since I have …


Data only Docker containers

In this post, we shall take a look at the idea of data only containers - containers whose sole purpose is to exist on the docker host so that other containers can have portable access to a persistent data volume.

Why do we need a persistent data volume?

We will experiment …


A virtualenv first approach to Python projects

I have until the last few months (of my ~4 years of working with Python) always worked without virtualenv for all my Python projects. Why? I think I found the whole idea of having to do the following two steps before I work on something cumbersome:

  • Remember the exact virtualenv …

PYTHONHASHSEED and your tests

Recently at work, I wanted to test a string which was being created by the urllib.urlencode() function. My first attempt was simple - test my expected string with that being created by the function above using unittest's assertEquals() function. It passed all the times I ran the tests before I …


Mounting a docker volume on SELinux enabled host

My workflow with docker usually involves volume mounting a host directory so that I can read and write to the host directory from my container as a non-root user. On a Fedora 23 host with SELinux enabled, this is what I have to do differently:

Use: -v /var/dir1:var …

Standalone open source puppet setup on Fedora

My goal in this post is to show how to setup puppet in standalone mode on a Fedora 23 system. This setup will allow writing puppet modules and then you can apply them on your local system and check manually and via serverspec tests that they are doing what you …


Fedora 22 Scientific

Fedora 22 was released recently which also means we have a new Fedora Scientific release. Fedora Scientific is now part of Fedora labs.

Featured Applications Image

As you can see, the new home for Fedora Scientific looks amazing. The "Featured Applications" section features the most important and useful tools in Fedora Scientific. I …


Remapping http://echorand.me

I changed the mapping of my domain to point to my GitHub pages. My old blog content is still available here.

© Amit Saha. Built using Pelican. Theme by Giulio Fidente on github.