Changeset 6502 for main


Ignore:
Timestamp:
3 Jul 2011, 19:15:25 (13 years ago)
Author:
uli
Message:

Add tests for file comparison.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/tests/test_helpers.py

    r6373 r6502  
    198198        self.assertTrue(result is None)
    199199
     200class CmpFilesTestCase(unittest.TestCase):
     201
     202    def setUp(self):
     203        self.workdir = tempfile.mkdtemp()
     204
     205    def tearDown(self):
     206        shutil.rmtree(self.workdir)
     207
     208    def test_equal(self):
     209        p1 = os.path.join(self.workdir, 'sample1')
     210        p2 = os.path.join(self.workdir, 'sample2')
     211        f1 = open(p1, 'wb').write('Hi!')
     212        f2 = open(p2, 'wb').write('Hi!')
     213        assert helpers.cmp_files(open(p1, 'r'), open(p2, 'r')) is True
     214
     215    def test_unequal(self):
     216        p1 = os.path.join(self.workdir, 'sample1')
     217        p2 = os.path.join(self.workdir, 'sample2')
     218        f1 = open(p1, 'wb').write('Hi!')
     219        f2 = open(p2, 'wb').write('Ho!')
     220        assert helpers.cmp_files(open(p1, 'r'), open(p2, 'r')) is False
     221
    200222def test_suite():
    201223    suite = unittest.TestSuite()
     
    207229        RemoveFileOrDirectoryTestCase,
    208230        CurrentPrincipalTestCase,
     231        CmpFilesTestCase,
    209232        ]:
    210233        suite.addTests(
Note: See TracChangeset for help on using the changeset viewer.