comparison test/test_mailgw.py @ 5036:380d8d8b30a3

Replace existing run_tests.py script with a pytest script The existing run_test.py script is quite old, a bit restrictive, and doesn't always behave as documented. The pytest testing tool is mature, well documented, and maintained. The run_tests.py script is generating by installing py.test and running: py.tests --genscript=run_tests.py Note: to generate a script that is compatible with python2.6 the command needs to be run using python2.6
author John Kristensen <john@jerrykan.com>
date Thu, 20 Aug 2015 18:15:23 +1000
parents 63c79c0992ae
children 364c54991861
comparison
equal deleted inserted replaced
5035:b5bb492e4b3c 5036:380d8d8b30a3
13 13
14 import email 14 import email
15 import gpgmelib 15 import gpgmelib
16 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, time 16 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, time
17 17
18 import pytest
19
18 try: 20 try:
19 import pyme, pyme.core 21 import pyme, pyme.core
22 SKIP_PGP = False
20 except ImportError: 23 except ImportError:
21 pyme = None 24 SKIP_PGP = True
25
26 skip_pgp = pytest.mark.skipif(
27 SKIP_PGP, reason="Skipping PGP tests: 'pyme' not installed")
22 28
23 29
24 from cStringIO import StringIO 30 from cStringIO import StringIO
25 31
26 if not os.environ.has_key('SENDMAILDEBUG'): 32 if not os.environ.has_key('SENDMAILDEBUG'):
3261 self.assertEqual(self.db.msg.get(msgid, 'files'), ['1']) 3267 self.assertEqual(self.db.msg.get(msgid, 'files'), ['1'])
3262 fileid = self.db.msg.get(msgid, 'files')[0] 3268 fileid = self.db.msg.get(msgid, 'files')[0]
3263 self.assertEqual(self.db.file.get(fileid, 'type'), 'message/rfc822') 3269 self.assertEqual(self.db.file.get(fileid, 'type'), 'message/rfc822')
3264 3270
3265 3271
3272 @skip_pgp
3266 class MailgwPGPTestCase(MailgwTestAbstractBase, unittest.TestCase): 3273 class MailgwPGPTestCase(MailgwTestAbstractBase, unittest.TestCase):
3267 pgphome = gpgmelib.pgphome 3274 pgphome = gpgmelib.pgphome
3268 def setUp(self): 3275 def setUp(self):
3269 MailgwTestAbstractBase.setUp(self) 3276 MailgwTestAbstractBase.setUp(self)
3270 self.db.security.addRole(name = 'pgp', description = 'PGP Role') 3277 self.db.security.addRole(name = 'pgp', description = 'PGP Role')

Roundup Issue Tracker: http://roundup-tracker.org/