Back to index

enigmail  1.4.3
Public Member Functions | Public Attributes
unit-buildlist.TestBuildList Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def touch
def assertFileContains
def test_basic
def test_append
def test_append_some
def test_add_multiple

Public Attributes

 tmpdir

Detailed Description

Unit tests for buildlist.py

Definition at line 10 of file unit-buildlist.py.


Member Function Documentation

def unit-buildlist.TestBuildList.assertFileContains (   self,
  filename,
  l 
)
Assert that the lines in the file |filename| are equal
to the contents of the list |l|, in order.

Definition at line 28 of file unit-buildlist.py.

00028 
00029   def assertFileContains(self, filename, l):
00030     """Assert that the lines in the file |filename| are equal
00031     to the contents of the list |l|, in order."""
00032     l = l[:]
00033     f = open(filename, 'r')
00034     lines = [line.rstrip() for line in f.readlines()]
00035     f.close()
00036     for line in lines:
00037       self.assert_(len(l) > 0, "ran out of expected lines! (expected '%s', got '%s')" % (l, lines))
00038       self.assertEqual(line, l.pop(0))
00039     self.assert_(len(l) == 0, "not enough lines in file! (expected '%s', got '%s'" % (l, lines))

Here is the call graph for this function:

Here is the caller graph for this function:

def unit-buildlist.TestBuildList.setUp (   self)

Definition at line 14 of file unit-buildlist.py.

00014 
00015   def setUp(self):
00016     self.tmpdir = mkdtemp()

def unit-buildlist.TestBuildList.tearDown (   self)

Definition at line 17 of file unit-buildlist.py.

00017 
00018   def tearDown(self):
00019     rmtree(self.tmpdir)

def unit-buildlist.TestBuildList.test_add_multiple (   self)
Test that attempting to add the same entry multiple times results in
only one entry being added.

Definition at line 70 of file unit-buildlist.py.

00070 
00071   def test_add_multiple(self):
00072     """Test that attempting to add the same entry multiple times results in
00073     only one entry being added."""
00074     testfile = os.path.join(self.tmpdir, "test.list")
00075     addEntriesToListFile(testfile, ["a","b","a","a","b"])
00076     self.assertFileContains(testfile, ["a","b"])
00077     addEntriesToListFile(testfile, ["c","a","c","b","c"])
00078     self.assertFileContains(testfile, ["a","b","c"])

Here is the call graph for this function:

def unit-buildlist.TestBuildList.test_append (   self)

Definition at line 50 of file unit-buildlist.py.

00050 
00051   def test_append(self):
00052     "Test adding new entries."
00053     testfile = os.path.join(self.tmpdir, "test.list")
00054     l = ["a", "b", "c"]
00055     addEntriesToListFile(testfile, l)
00056     self.assertFileContains(testfile, l)
00057     l2 = ["x","y","z"]
00058     addEntriesToListFile(testfile, l2)
00059     l.extend(l2)
00060     self.assertFileContains(testfile, l)

Here is the call graph for this function:

def unit-buildlist.TestBuildList.test_append_some (   self)

Definition at line 61 of file unit-buildlist.py.

00061 
00062   def test_append_some(self):
00063     "Test adding new entries mixed with existing entries."
00064     testfile = os.path.join(self.tmpdir, "test.list")
00065     l = ["a", "b", "c"]
00066     addEntriesToListFile(testfile, l)
00067     self.assertFileContains(testfile, l)
00068     addEntriesToListFile(testfile, ["a", "x", "c", "z"])
00069     self.assertFileContains(testfile, ["a", "b", "c", "x", "z"])

Here is the call graph for this function:

def unit-buildlist.TestBuildList.test_basic (   self)

Definition at line 40 of file unit-buildlist.py.

00040 
00041   def test_basic(self):
00042     "Test that addEntriesToListFile works when file doesn't exist."
00043     testfile = os.path.join(self.tmpdir, "test.list")
00044     l = ["a", "b", "c"]
00045     addEntriesToListFile(testfile, l)
00046     self.assertFileContains(testfile, l)
00047     # ensure that attempting to add the same entries again doesn't change it
00048     addEntriesToListFile(testfile, l)
00049     self.assertFileContains(testfile, l)

Here is the call graph for this function:

def unit-buildlist.TestBuildList.touch (   self,
  file,
  dir = None 
)

Definition at line 21 of file unit-buildlist.py.

00021 
00022   def touch(self, file, dir=None):
00023     if dir is None:
00024       dir = self.tmpdir
00025     f = os.path.join(dir, file)
00026     open(f, 'w').close()
00027     return f

Here is the caller graph for this function:


Member Data Documentation

unit-buildlist.TestBuildList.tmpdir

Definition at line 15 of file unit-buildlist.py.


The documentation for this class was generated from the following file: