Faking a time stamp from time.time() in Nose
<p>I'm building a device object to poll data from connected devices in python and I'm trying to test the inter workings of the object and all it's functions using nose. I am running into a problem in general when writing a timestamp using <code>time.time()</code> as each time the function is called the result the value is different and this seriously screws up some test, for example this data collection function:</p>

<pre><code>def getData(self, data):
    if type(data) is not type({}):
        #print "Bad Type!"
        raise TypeError
    else:
        #print "Good Type!"
        self.outD = {}
        datastr = ""
        for key, value in data.iteritems():
            self.outD[key] = value
        self.outD["timestamp"] = time.time()
        self.outD["id"] = self.id
        self._writeCSV()
</code></pre>

<p>When I test the output of this function and compare the generated CSV file, it always fails due to the time stamp. I can sub it out in my device object by adding testing flags, but I was wondering if nose has a built in way to deal with issues like this where the result of a function can be substituted with a given value or a local function to fake the <code>time.time()</code> call. Is this possible?</p>