Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/testutils.py
blob: 2f3e7ff77550ea3c972278b1fae01afa7605da7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import tempfile
import os

def tmpData(data):
    """Put data into a temporary file returning the filename """
    fd, fn = tempfile.mkstemp()
    os.write(fd, data)
    os.close(fd)
    return fn

def blit(data, path=None):
    if not path: return tmpData(data)
    fp = open(path, 'w')
    fp.write(data)
    fp.close()
    return path


# Search result set handlers
def expect(r, count=None):
   if count: assert r[1] == count
   return list(r[0])
def expect_single(r):
   assert r[1] == 1
   return r[0].next()
def expect_none(r):
   assert r[1] == 0
   assert list(r[0]) == []