Exemple #1
0
def suite():
    t_suite = unittest.TestSuite()
    t_suite.addTest(
        unittest.TestLoader().loadTestsFromTestCase(CheckerTestCase))
    t_suite.addTest(
        unittest.TestLoader().loadTestsFromTestCase(ContextTestCase))
    return t_suite
Exemple #2
0
def suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(EVPTestCase))
    suite.addTest(unittest.makeSuite(CipherTestCase))
    suite.addTest(unittest.makeSuite(PBKDF2TestCase))
    suite.addTest(unittest.makeSuite(HMACTestCase))
    return suite
Exemple #3
0
def test_suite():
    return unittest.TestSuite([
        unittest.makeSuite(ProductEnvTestCase, 'test'),
        unittest.makeSuite(ProductEnvApiTestCase, 'test'),
        unittest.makeSuite(ProductEnvHrefTestCase, 'test'),
        unittest.makeSuite(ProductEnvConfigTestCase, 'test'),
    ])
Exemple #4
0
def suite():
    st = unittest.TestSuite()
    st.addTest(unittest.TestLoader().loadTestsFromTestCase(X509TestCase))
    st.addTest(unittest.TestLoader().loadTestsFromTestCase(X509StackTestCase))
    st.addTest(unittest.TestLoader().loadTestsFromTestCase(X509ExtTestCase))
    st.addTest(unittest.TestLoader().loadTestsFromTestCase(CRLTestCase))
    return st
Exemple #5
0
    def run(self):
        # Installing required packages and running egg_info and are
        # part of normal operation for setuptools.command.test.test
        if self.distribution.install_requires:
            self.distribution.fetch_build_eggs(
                self.distribution.install_requires)
        if self.distribution.tests_require:
            self.distribution.fetch_build_eggs(self.distribution.tests_require)
        self.run_command('egg_info')

        # Construct a TextTestRunner directly from the unittest imported from
        # test (this will be unittest2 under Python 2.6), which creates a
        # TestResult that supports the 'addSkip' method. setuptools will by
        # default create a TextTestRunner that uses the old TestResult class,
        # resulting in DeprecationWarnings instead of skipping tests under 2.6.
        from tests import unittest
        if self.test_suite is None:
            all_tests = unittest.defaultTestLoader.discover(self.test_module)
            suite = unittest.TestSuite(tests=all_tests)
        else:
            suite = unittest.defaultTestLoader.loadTestsFromName(
                self.test_suite)
        result = unittest.TextTestRunner(verbosity=2,
                                         failfast=self.failfast).run(suite)
        sys.exit(not result.wasSuccessful())
Exemple #6
0
def suite():
    st = unittest.TestSuite()
    st.addTest(unittest.makeSuite(X509TestCase))
    st.addTest(unittest.makeSuite(X509StackTestCase))
    st.addTest(unittest.makeSuite(X509ExtTestCase))
    st.addTest(unittest.makeSuite(CRLTestCase))
    return st
def suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(SessionTestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(XmlRpcLibTestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(FtpsLibTestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(PassSSLClientTestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(HttpslibSSLClientTestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(HttpslibSSLSNIClientTestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(UrllibSSLClientTestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(Urllib2SSLClientTestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(Urllib2TEChunkedSSLClientTestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(MiscSSLClientTestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(FtpslibTestCase))
    try:
        import M2Crypto.SSL.TwistedProtocolWrapper as wrapper  # noqa
        suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TwistedSSLClientTestCase))
    except ImportError:
        pass
    return suite
Exemple #8
0
def test_suite():
    return unittest.TestSuite([
        unittest.makeSuite(MultiProductExtensionPointTestCase, 'test'),
    ])
Exemple #9
0
def suite():
    test_suite = unittest.TestSuite()
    test_suite.addTest(unittest.makeSuite(ProductTestCase, 'test'))
    return test_suite
Exemple #10
0
def suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(UtilTestCase))
    return suite
Exemple #11
0
def main(argv=None):
	'''Run either all tests, or those specified in argv'''
	if argv is None:
		argv = sys.argv

	# parse options
	coverage = None
	failfast = False
	loglevel = logging.WARNING
	opts, args = getopt.gnu_getopt(argv[1:],
		'hVD', ['help', 'coverage', 'fast', 'failfast', 'debug', 'verbose'])
	for o, a in opts:
		if o in ('-h', '--help'):
			print '''\
usage: %s [OPTIONS] [MODULES]

Where MODULE should a module name from ./tests/
If no module is given the whole test suite is run.

Options:
  -h, --help     print this text
  --fast         skip a number of slower tests (assumes --failfast)
  --failfast     stop after the first test that fails
  --coverage     report test coverage statistics
  -V, --verbose  run with verbose output from logging
  -D, --debug    run with debug output from logging
''' % argv[0]
			return
		elif o == '--coverage':
			try:
				import coverage as coverage_module
			except ImportError:
				print >>sys.stderr, '''\
Can not run test coverage without module 'coverage'.
On Ubuntu or Debian install package 'python-coverage'.
'''
				sys.exit(1)
			#~ coverage = coverage_module.coverage(data_suffix=True, auto_data=True)
			coverage = coverage_module.coverage(data_suffix=True)
			coverage.erase() # clean up old date set
			coverage.exclude('assert ')
			coverage.exclude('raise NotImplementedError')
			coverage.start()
		elif o == '--fast':
			failfast = True
			tests.FAST_TEST = True
				# set before any test classes are loaded !
		elif o == '--failfast':
			failfast = True
		elif o in ('-V', '--verbose'):
			loglevel = logging.INFO
		elif o in ('-D', '--debug'):
			loglevel = logging.DEBUG
		else:
			assert False

	# Set logging handler
	logging.basicConfig(level=loglevel, format='%(levelname)s: %(message)s')

	# Build the test suite
	loader = unittest.TestLoader()
	if args:
		suite = unittest.TestSuite()
		for name in args:
			module = name if name.startswith('tests.') else 'tests.' + name
			test = loader.loadTestsFromName(module)
			suite.addTest(test)
	else:
		suite = tests.load_tests(loader, None, None)

	# And run it
	unittest.installHandler() # Fancy handling for ^C during test
	result = \
		unittest.TextTestRunner(verbosity=2, failfast=failfast, descriptions=False).run(suite)

	# Check the modules were loaded from the right location
	# (so no testing based on modules from a previous installed version...)
	mylib = os.path.abspath('./zim')
	for module in [m for m in sys.modules.keys()
			if m == 'zim' or m.startswith('zim.')]:
				if sys.modules[module] is None:
					continue
				file = sys.modules[module].__file__
				assert file.startswith(mylib), \
					'Module %s was loaded from %s' % (module, file)

	test_report(result, 'test_report.html')
	print '\nWrote test report to test_report.html\n'

	# Create coverage output if asked to do so
	if coverage:
		coverage.stop()
		#~ coverage.combine()

		print 'Writing coverage reports...'

		pyfiles = list(tests.zim_pyfiles())
		#~ coverage.report(pyfiles, show_missing=False)
		#~ coverage.html_report(pyfiles, directory='./coverage', omit=['zim/inc/*'])
		coverage_report(coverage, pyfiles, './coverage')
		print 'Done - Coverage reports can be found in ./coverage/'
Exemple #12
0
def suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(ThreadingTestCase))
    return suite
def suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(RandTestCase))
    return suite
Exemple #14
0
def suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(SMIMETestCase))
    suite.addTest(unittest.makeSuite(WriteLoadTestCase))
    return suite
Exemple #15
0
def test_suite():
    return unittest.TestSuite([
        unittest.makeSuite(ProductizedHrefTestCase, 'test')
    ])
Exemple #16
0
def suite():
    t_suite = unittest.TestSuite()
    t_suite.addTest(unittest.makeSuite(AESTestCase))
    return t_suite
Exemple #17
0
def test_suite():
    return unittest.TestSuite([
        unittest.makeSuite(ProductPygmentsRendererTestCase, 'test'),
    ])
Exemple #18
0
def suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(SMIMETestCase))
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(WriteLoadTestCase))
    return suite
Exemple #19
0
        self.assertTrue(db.authenticate('user', 'userpass'))
        self.assertTrue(db.foo.insert({'foo': 'bar'}, w=2, wtimeout=1000))
        self.assertTrue(isinstance(db.foo.find_one(), dict))
        db.logout()
        self.assertRaises(pymongo.errors.OperationFailure, db.foo.find_one)

    def test_auth_arbiter_member_info(self):
        self.repl = ReplicaSet(
            {'members': [{}, {
                'rsParams': {
                    'arbiterOnly': True
                }
            }]})
        info = self.repl.member_info(1)
        for key in ('procInfo', 'mongodb_uri', 'statuses', 'rsInfo'):
            self.assertIn(key, info)
        rs_info = info['rsInfo']
        for key in ('primary', 'secondary', 'arbiterOnly'):
            self.assertIn(key, rs_info)
        self.assertFalse(rs_info['primary'])
        self.assertFalse(rs_info['secondary'])
        self.assertTrue(rs_info['arbiterOnly'])


if __name__ == '__main__':
    # unittest.main(verbosity=3)
    suite = unittest.TestSuite()
    suite.addTest(ReplicaSetTestCase('test_member_freeze'))
    suite.addTest(ReplicaSetsTestCase('test_member_freeze'))
    unittest.TextTestRunner(verbosity=2).run(suite)
def suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(ECCurveTests))
    return suite
def suite():
    t_suite = unittest.TestSuite()
    t_suite.addTest(unittest.makeSuite(CheckerTestCase))
    t_suite.addTest(unittest.makeSuite(ContextTestCase))
    return t_suite
Exemple #22
0
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(EnvironmentUpgradeTestCase, 'test'))
    return suite
Exemple #23
0
def suite():
    t_suite = unittest.TestSuite()
    t_suite.addTest(unittest.makeSuite(CipherStreamTestCase))
    return t_suite
Exemple #24
0
def suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(ECCurveTests))
    return suite
Exemple #25
0
def suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TimeoutTestCase))
    return suite
Exemple #26
0
def suite():
    t_suite = unittest.TestSuite()
    t_suite.addTest(unittest.TestLoader().loadTestsFromTestCase(AESTestCase))
    return t_suite
Exemple #27
0
def main(argv=None):
	'''Run either all tests, or those specified in argv'''
	if argv is None:
		argv = sys.argv

	# parse options
	covreport = False
	failfast = False
	loglevel = logging.WARNING
	opts, args = getopt.gnu_getopt(argv[1:],
		'hVD', ['help', 'coverage', 'fast', 'failfast', 'ff', 'full', 'debug', 'verbose'])
	for o, a in opts:
		if o in ('-h', '--help'):
			print '''\
usage: %s [OPTIONS] [MODULES]

Where MODULE should a module name from ./tests/
If no module is given the whole test suite is run.

Options:
  -h, --help     print this text
  --fast         skip a number of slower tests and mock filesystem
  --failfast     stop after the first test that fails
  --ff           alias for "--fast --failfast"
  --full         full test for using filesystem without mock
  --coverage     report test coverage statistics
  -V, --verbose  run with verbose output from logging
  -D, --debug    run with debug output from logging
''' % argv[0]
			return
		elif o == '--coverage':
			if coverage:
				covreport = True
			else:
				print >>sys.stderr, '''\
Can not run test coverage without module 'coverage'.
On Ubuntu or Debian install package 'python-coverage'.
'''
				sys.exit(1)
		elif o == '--fast':
			tests.FAST_TEST = True
				# set before any test classes are loaded !
		elif o == '--failfast':
			failfast = True
		elif o == '--ff': # --fast --failfast
			tests.FAST_TEST = True
			failfast = True
		elif o == '--full':
			tests.FULL_TEST = True
		elif o in ('-V', '--verbose'):
			loglevel = logging.INFO
		elif o in ('-D', '--debug'):
			loglevel = logging.DEBUG
		else:
			assert False, 'Unkown option: %s' % o

	# Start tracing
	if coverage:
		cov = coverage.coverage(source=['zim'], branch=True)
		cov.erase() # clean up old date set
		cov.exclude('assert ')
		cov.exclude('raise NotImplementedError')
		cov.start()

	# Set logging handler (don't use basicConfig here, we already installed stuff)
	handler = logging.StreamHandler()
	handler.setFormatter(logging.Formatter('%(levelname)s: %(message)s'))
	logger = logging.getLogger()
	logger.setLevel(loglevel)
	logger.addHandler(handler)
	#logging.captureWarnings(True) # FIXME - make all test pass with this enabled

	# Build the test suite
	loader = unittest.TestLoader()
	try:
		if args:
			suite = unittest.TestSuite()
			for name in args:
				module = name if name.startswith('tests.') else 'tests.' + name
				test = loader.loadTestsFromName(module)
				suite.addTest(test)
		else:
			suite = tests.load_tests(loader, None, None)
	except AttributeError as error:
		# HACK: unittest raises and attribute errors if import of test script
		# fails try to catch this and show the import error instead - else raise
		# original error
		import re
		m = re.match(r"'module' object has no attribute '(\w+)'", error.args[0])
		if m:
			module = m.group(1)
			m = __import__('tests.' + module) # should raise ImportError
		raise error

	# And run it
	unittest.installHandler() # Fancy handling for ^C during test
	result = \
		unittest.TextTestRunner(verbosity=2, failfast=failfast, descriptions=False).run(suite)

	# Check the modules were loaded from the right location
	# (so no testing based on modules from a previous installed version...)
	mylib = os.path.abspath('./zim')
	for module in [m for m in sys.modules.keys()
			if m == 'zim' or m.startswith('zim.')]:
				if sys.modules[module] is None:
					continue
				file = sys.modules[module].__file__
				assert file.startswith(mylib), \
					'Module %s was loaded from %s' % (module, file)

	test_report(result, 'test_report.html')
	print '\nWrote test report to test_report.html\n'

	# Stop tracing
	if coverage:
		cov.stop()
		cov.save()

	# Create coverage output if asked to do so
	if covreport:
		print 'Writing coverage reports...'
		cov.html_report(directory='./coverage', omit=['zim/inc/*'])
		print 'Done - Coverage reports can be found in ./coverage/'
Exemple #28
0
def main(argv=None):
	'''Run either all tests, or those specified in argv'''
	if argv is None:
		argv = sys.argv

	# parse options
	covreport = False
	failfast = False
	loglevel = logging.WARNING
	opts, args = getopt.gnu_getopt(argv[1:],
		'hVD', ['help', 'coverage', 'fast', 'failfast', 'ff', 'full', 'debug', 'verbose'])
	for o, a in opts:
		if o in ('-h', '--help'):
			print '''\
usage: %s [OPTIONS] [MODULES]

Where MODULE should a module name from ./tests/
If no module is given the whole test suite is run.

Options:
  -h, --help     print this text
  --fast         skip a number of slower tests and mock filesystem
  --failfast     stop after the first test that fails
  --ff           alias for "--fast --failfast"
  --full         full test for using filesystem without mock
  --coverage     report test coverage statistics
  -V, --verbose  run with verbose output from logging
  -D, --debug    run with debug output from logging
''' % argv[0]
			return
		elif o == '--coverage':
			if coverage:
				covreport = True
			else:
				print >>sys.stderr, '''\
Can not run test coverage without module 'coverage'.
On Ubuntu or Debian install package 'python-coverage'.
'''
				sys.exit(1)
		elif o == '--fast':
			tests.FAST_TEST = True
				# set before any test classes are loaded !
		elif o == '--failfast':
			failfast = True
		elif o == '--ff': # --fast --failfast
			tests.FAST_TEST = True
			failfast = True
		elif o == '--full':
			tests.FULL_TEST = True
		elif o in ('-V', '--verbose'):
			loglevel = logging.INFO
		elif o in ('-D', '--debug'):
			loglevel = logging.DEBUG
		else:
			assert False, 'Unkown option: %s' % o

	# Start tracing
	if coverage:
		cov = coverage.coverage(source=['zim'], branch=True)
		cov.erase() # clean up old date set
		cov.exclude('assert ')
		cov.exclude('raise NotImplementedError')
		cov.start()

	# Set logging handler (don't use basicConfig here, we already installed stuff)
	handler = logging.StreamHandler()
	handler.setFormatter(logging.Formatter('%(levelname)s: %(message)s'))
	logger = logging.getLogger()
	logger.setLevel(loglevel)
	logger.addHandler(handler)

	# Build the test suite
	loader = unittest.TestLoader()
	try:
		if args:
			suite = unittest.TestSuite()
			for name in args:
				module = name if name.startswith('tests.') else 'tests.' + name
				test = loader.loadTestsFromName(module)
				suite.addTest(test)
		else:
			suite = tests.load_tests(loader, None, None)
	except AttributeError, error:
		# HACK: unittest raises and attribute errors if import of test script
		# fails try to catch this and show the import error instead - else raise
		# original error
		import re
		m = re.match(r"'module' object has no attribute '(\w+)'", error.args[0])
		if m:
			module = m.group(1)
			m = __import__('tests.'+module) # should raise ImportError
		raise error