diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2012-02-03 13:46:08 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2012-02-03 13:46:08 +0100 |
| commit | 7e0a6a8421d0b1de85a69fad80c24b494385a1bf (patch) | |
| tree | 722a8a754e5c2bc98f8f530c74be74b9a0eba36c /tests | |
| parent | 70e5581fa92082cc47ebadd0ae5e2cbcf928853d (diff) | |
| download | python-apt-7e0a6a8421d0b1de85a69fad80c24b494385a1bf.tar.gz | |
* python/tag.cc, tests/test_tagfile.py:
- add support a filename argument in apt_pkg.TagFile() (in addition
to the file object currently supported)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_tagfile.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/test_tagfile.py b/tests/test_tagfile.py index b14dd9b4..371cc6ee 100644 --- a/tests/test_tagfile.py +++ b/tests/test_tagfile.py @@ -7,6 +7,7 @@ # notice and this notice are preserved. """Unit tests for verifying the correctness of apt_pkg.TagFile""" +import glob import os import unittest @@ -21,22 +22,21 @@ class TestTagFile(unittest.TestCase): def test_tag_file(self): basepath = os.path.dirname(__file__) - tagfilepath = os.path.join( - basepath, "./data/tagfile/history.log") - tagfile = apt_pkg.TagFile(open(tagfilepath)) - for i, stanza in enumerate(tagfile): - pass - self.assertEqual(i, 2) + tagfilepath = os.path.join(basepath, "./data/tagfile/*") + # test once for compressed and uncompressed + for testfile in glob.glob(tagfilepath): + # test once using the open() method and once using the path + for f in [testfile, open(testfile)]: + tagfile = apt_pkg.TagFile(f) + for i, stanza in enumerate(tagfile): + pass + self.assertEqual(i, 2) - def test_tag_file_compressed(self): - basepath = os.path.dirname(__file__) - tagfilepath = os.path.join( - basepath, "./data/tagfile/history.1.log.gz") - tagfile = apt_pkg.TagFile(open(tagfilepath)) - for i, stanza in enumerate(tagfile): - #print stanza - pass - self.assertEqual(i, 2) + def test_errors(self): + # Raises SystemError via lbiapt + self.assertRaises(SystemError, apt_pkg.TagFile, "not-there-no-no") + # Raises Type error + self.assertRaises(TypeError, apt_pkg.TagFile, object()) if __name__ == "__main__": unittest.main() |
