Beispiel #1
0
def suite():
    suite = TestSuite()
    suite.addTest(TestLoader().loadTestsFromTestCase(TestScript))
    suite.addTest(TestLoader().loadTestsFromTestCase(TestCountry))
    suite.addTest(TestLoader().loadTestsFromTestCase(TestLanguage))
    return suite
Beispiel #2
0
from unit_tests.test_linear_regression import TestLinearRegression
from unit_tests.test_ridge_regression import TestRidgeRegression
from unittest import TestLoader, TextTestRunner, TestSuite

# Uses a testLoader to run multiple tests from different python unit tests file
if __name__ == "__main__":

    loader = TestLoader()

    suite = TestSuite((loader.loadTestsFromTestCase(TestLinearRegression),
                       loader.loadTestsFromTestCase(TestRidgeRegression)))

    runner = TextTestRunner()
    runner.run(suite)
Beispiel #3
0
from unittest import TestLoader, TestSuite
from pyunitreport import HTMLTestRunner
from assertions import AssertionTest
from searchtest import SearchTest

assertion_test = TestLoader().loadTestsFromTestCase(AssertionTest)
search_test = TestLoader().loadTestsFromTestCase(SearchTest)

smoke_test = TestSuite([search_test, assertion_test])

kwargs = {"output": 'smoke-report'}

runner = HTMLTestRunner(**kwargs)
runner.run(smoke_test)
Beispiel #4
0
def test_suite():
    suite = TestLoader().loadTestsFromName(__name__)
    suite.addTest(DocTestSuite(lp.soyuz.scripts.gina.handlers))
    return suite
	def __init__(self, test_case_class):
		my_load = TestLoader()
		self.methods = my_load.getTestCaseNames(test_case_class)
Beispiel #6
0
  def run(self):

    loader = TestLoader()
    tests = loader.discover(start_dir='tests')
    runner = TextTestRunner(verbosity=2)
    runner.run(tests)
Beispiel #7
0
 def run_tests(self):
     from unittest import TestLoader, TextTestRunner
     tests_dir = pjoin(dirname(__file__), 'tests')
     suite = TestLoader().discover(tests_dir)
     result = TextTestRunner().run(suite)
     sys.exit(0 if result.wasSuccessful() else -1)
Beispiel #8
0
    def test_1_gradient(self):
        img = im_data.imread('image.jpg')
        img = im_color.rgb2gray(img)

        gd = two_neighbors_gradient(img)

        blurred = blur(img, (9, 9))
        gd2 = two_neighbors_gradient(blurred)

        sh1 = mean(gd) * 256
        sh2 = mean(gd2) * 256

        self.assertGreater(sh1, sh2, 'Original sharpness should be bigger!')

    def test_2_shb(self):
        img = im_data.imread('image.jpg')
        img = im_color.rgb2gray(img)
        img = resize(img, None, fx=0.5, fy=0.5)

        features = sharpness_behavior(img)

        self.assertEqual(len(features), 5,
                         'The features returned should have 5'
                         ' values')


if __name__ == '__main__':
    # loads and runs the Unit Tests
    suite = TestLoader().loadTestsFromTestCase(SHBTests)
    TextTestRunner(verbosity=2, ).run(suite)
Beispiel #9
0
def suite():
    """ returns all the testcases in this module """
    return TestLoader().loadTestsFromTestCase(EasyConfigVersion)
Beispiel #10
0
            return
        self.fail(u"Expected exception")

    def testLocalFilesAreNotRead(self):
        try:
            getHtmlSafely("/etc/passwd")
        except HttpException, e:
            return
        self.fail(u"Expected exception")

    def testFtpIsNotAllowed(self):
        try:
            getHtmlSafely("ftp:localhost")
        except HttpException, e:
            return
        self.fail(u"Expected exception")

    def testFtpIsNotAllowedWithProtocolAutoDetect(self):
        try:
            getHtmlSafely("ftp.funet.fi")
        except HttpException, e:
            self.failUnless(ERR_FORBIDDEN_SCHEME in e.parameter)
            return
        self.fail(u"Expected exception")


if __name__ == "__main__":
    suite = TestLoader().loadTestsFromTestCase(VoikkoHtmlTest)
    #suite = TestLoader().loadTestsFromName("voikkohtmlTest.VoikkoHtmlTest.testCorrectCommentParsing")
    TextTestRunner(verbosity=1).run(suite)
Beispiel #11
0
def make_test_suite():
    """Load unittests placed in pybrain/tests/unittests, then return a
    TestSuite object of those."""
    # [...]/pybrain/pybrain [cut] /tests/runtests.py
    path = os.path.abspath(__file__).rsplit(os.sep + 'tests', 1)[0]

    sys.path.append(path.rstrip('pybrain'))

    top_testdir = os.path.join(path, 'tests', 'unittests')
    testdirs = getSubDirectories(top_testdir)

    # Initialize the testsuite to add to
    suite = TestSuite()
    optionflags = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.IGNORE_EXCEPTION_DETAIL

    for testdir in testdirs:
        # All unittest modules have to start with 'test_' and have to be, of
        # course, python files
        module_names = [
            f[:-3] for f in os.listdir(testdir)
            if f.startswith('test_') and f.endswith('.py')
        ]

        if not module_names:
            logging.info('No tests found in %s' % testdir)
            continue

        # "Magically" import the tests package and its test-modules that we've
        # found
        test_package_path = 'pybrain.tests.unittests'
        sub_path = os.path.relpath(testdir, top_testdir).split(os.sep)
        test_package_path = '.'.join([test_package_path] + sub_path)
        test_package = __import__(test_package_path, fromlist=module_names)

        # Put the test modules in a list that can be passed to the testsuite
        modules = (getattr(test_package, n) for n in module_names)
        modules = [(m, missingDependencies(m)) for m in modules]
        untests = [(m, md) for m, md in modules if md]
        modules = [m for m, md in modules if not md]

        # print(out modules that are missing dependencies)
        for module, miss_dep in untests:  # Mr Dep is not around, though
            logging.warning('Module %s is missing dependencies: %s' %
                            (module.__name__, ', '.join(miss_dep)))

        # print(out a list of tests that are found)
        for m in modules:
            logging.info('Tests found: %s' % m.__name__)

        # Build up the testsuite
        suite.addTests([TestLoader().loadTestsFromModule(m) for m in modules])

        # Add doctests from the unittest modules to the suite
        for mod in modules:
            try:
                suite.addTest(
                    doctest.DocTestSuite(mod, optionflags=optionflags))
            except ValueError:
                # No tests found.
                pass

    return suite
Beispiel #12
0
    # -----
    if arguments.get("console", False):
        for item in LOGGERS:
            with suppress(KeyError):
                config["loggers"][item]["handlers"] = ["file", "console"]
        with suppress(KeyError):
            config["handlers"]["console"]["level"] = "DEBUG"
        config["handlers"]["console"]["func"] = partial(cf, attrgetter_("funcName")(partial(operator.contains, arguments.get("console", []))))

    # -----
    logging.config.dictConfig(config)
    logger = logging.getLogger("MyPythonProject.{0}".format(os.path.splitext(os.path.basename(os.path.abspath(__file__)))[0]))

# ================
# Run main script.
# ================
verbosity = arguments.get("verbosity", 1)
if verbosity > 2:
    verbosity = 2
suite, loader, runner = TestSuite(), TestLoader(), TextTestRunner(verbosity=verbosity)
suite.addTests(loader.loadTestsFromModule(module1))
suite.addTests(loader.loadTestsFromModule(module2))
suite.addTests(loader.loadTestsFromModule(module3))
suite.addTests(loader.loadTestsFromModule(module4))
suite.addTests(loader.loadTestsFromModule(module5))
if Path("F:/").exists():
    from Applications.Unittests import module6
    suite.addTests(loader.loadTestsFromModule(module6))
result = runner.run(suite)
sys.exit(EXIT[result.wasSuccessful()])
Beispiel #13
0
def add_tests_to_suite(suite, test_modules):
    suite.addTests([
        TestLoader().loadTestsFromModule(test_module)
        for test_module in test_modules
    ])
Beispiel #14
0
            tls.reportTCResult(None, 2, None, 'b', 'skip', guess=True,
                               testcaseexternalid='11-2',
                               platformname='NewPlatform',
                               execduration=1.9, timestamp='2018-06-04 23:00',
                               steps=[{'step_number': 1, 'result': "fail", 'notes': 'skip'}])


if __name__ == '__main__':
    # redirector default output of unittest to /dev/null
    with open(os.devnull, 'w') as null_stream:
        # new a runner and overwrite resultclass of runner
        runner = TextTestRunner(stream=null_stream)
        runner.resultclass = JsonTestResult

        # create a testsuite
        suite = TestLoader().loadTestsFromTestCase(TestSimple)

        # run the testsuite
        result = runner.run(suite)

        # print json output
        print("\nresult.jsonify()")
        pprint(result.jsonify())

        TESTLINK_API_PYTHON_SERVER_URL = "http://192.168.1.161/lib/api/xmlrpc/v1/xmlrpc.php"
        TESTLINK_API_PYTHON_DEVKEY = "0dc10c05acc7320bb5a0a793b6b08c97"

        # tls = testlink.TestLinkHelper( TESTLINK_API_PYTHON_SERVER_URL, TESTLINK_API_PYTHON_DEVKEY).connect(testlink.TestlinkAPIClient)

        tlh = testlink.TestLinkHelper(TESTLINK_API_PYTHON_SERVER_URL, TESTLINK_API_PYTHON_DEVKEY)
        tls = testlink.TestlinkAPIClient(tlh._server_url, tlh._devkey, verbose=True)
Beispiel #15
0
def suite():
    suite = TestSuite()
    suite.addTest(TestLoader().loadTestsFromTestCase(PackagesTestCase))
    return suite
Beispiel #16
0
 def run(self):
     test_suite = TestLoader().discover('./tests', pattern='*_test.py')
     test_results = TextTestRunner(verbosity=2).run(test_suite)
Beispiel #17
0
def main():
    tl = TestLoader()
    suite = tl.loadTestsFromTestCase(ChipHardwareTest)
    # This runs the whole suite of tests. For now, using TextTestRunner
    result = TextTestRunner(verbosity=2, failfast=True).run(suite)
    print result
Beispiel #18
0
def allTests(testClass):
    return TestLoader().loadTestsFromTestCase(testClass)
Beispiel #19
0
 def suite(self):
     """Return all the testcases in this module."""
     return TestLoader().loadTestsFromTestCase(PanHandlerTest)
Beispiel #20
0
        self.assertRaises(Exception,
                          solventlibrary.load_entry,
                          index=4,
                          label='benzene',
                          solvent=None,
                          molecule='ring')

        # Case 5: when the solventDatabase contains data for co-solvents.
        solventlibrary.load_entry(index=5,
                                  label='methanol_50_water_50',
                                  solvent=None,
                                  molecule=['CO', 'O'])
        solvent_species_list = [
            Species().from_smiles('CO'),
            Species().from_smiles('O')
        ]
        self.assertEqual(
            len(solventlibrary.entries['methanol_50_water_50'].item), 2)
        for spc1 in solventlibrary.entries['methanol_50_water_50'].item:
            self.assertTrue(
                any([
                    spc1.is_isomorphic(spc2) for spc2 in solvent_species_list
                ]))


#####################################################

if __name__ == '__main__':
    suite = TestLoader().loadTestsFromTestCase(TestSoluteDatabase)
    TextTestRunner(verbosity=2).run(suite)
Beispiel #21
0
    def test_learner_kwargs(self):
        """

        Returns:

        """
        my_learner = baseline_learner.BaselineLearner
        data_arff = arff.Arff(self.arff_path, label_count=1)
        session = manager.ToolkitSession(arff=self.arff_path, learner=my_learner, data=data_arff, example_hyperparameter=.5, label_count=1)
        self.assertEqual(session.learner.data_shape,(690,16))
        self.assertEqual(session.learner.example_hyperparameter, .5)


    def test_confusion_matrix(self):
        my_learner = baseline_learner.BaselineLearner
        data_arff = arff.Arff(self.arff_path, label_count=1)
        session = manager.ToolkitSession(arff=self.arff_path, learner=my_learner, data=data_arff, example_hyperparameter=.5, label_count=1)
        session.train()
        cm = session.learner.get_confusion_matrix(data_arff.get_features(), data_arff.get_labels())
        self.assertEqual('383',cm[-1,-1])

    def test_multidimensional_label(self):
        pass


if __name__=="__main__":
    print("here")
    suite = TestLoader().loadTestsFromTestCase(TestManager)
    TextTestRunner(verbosity=2).run(suite)
                        quantum_pauli_y_transform_20_qubits_array_expected_amplitudes,
                        rtol=1e-7, atol=1e-7)
        """
        Perform the Assertion of all close values in the values of the quantum_regime state,
        represented by its state vector describing the given qubit,
        after be applied the Qiskrypt's Quantum Pauli-Y Transform.
        """

        """
        Dummy Assert Equal for the Unittest.
        """
        self.assertEqual(True, True)


if __name__ == "__main__":
    """
    The Main Method for the Unitary Test.
    """

    qiskrypt_quantum_pauli_y_transform_test_cases = \
        TestLoader().loadTestsFromTestCase(QiskryptQuantumPauliYTransformTests)
    """
    Load the Test Cases from the Unitary Tests for the Qiskrypt's Quantum Pauli-Y Transform.
    """

    qiskrypt_quantum_pauli_y_transform_test_suite = \
        TestSuite([qiskrypt_quantum_pauli_y_transform_test_cases])
    """
    Load the Test Suite with all the Test Cases for the Qiskrypt's Quantum Pauli-Y Transform.
    """
def suite():
    """ returns all the testcases in this module """
    return TestLoader().loadTestsFromTestCase(ScriptsTest)
Beispiel #24
0
# -*- coding: utf-8 -*-
from unittest import TestLoader, TextTestRunner

try:
    import pymongo
except ImportError:
    print('Pymongo module is required')

try:
    import gst
except ImportError:
    print('Gst python binding is required')

if __name__ == "__main__":
    test_loader = TestLoader()
    suit = test_loader.discover('tests/', pattern='test*.py')
    res = TextTestRunner(verbosity=1).run(suit)

    raise SystemExit(not res.wasSuccessful())
Beispiel #25
0
def suite():
    """ return all the tests in this file """
    return TestLoader().loadTestsFromTestCase(ToyBuildTest)
Beispiel #26
0
#!/usr/bin/env python3

import sys
from getopt import getopt
from os.path import dirname
from unittest import TestLoader, TextTestRunner


def createTestRunner():
	opts, _ = getopt(sys.argv[1:], '', ['xml='])
	for o, v in opts:
		if o == '--xml':
			from xmlrunner import XMLTestRunner
			return XMLTestRunner(output=open(v, 'wb'))
	return TextTestRunner()


if __name__ == '__main__':
	cwd = dirname(sys.argv[0])
	suite = TestLoader().discover(cwd + '/test')
	runner = createTestRunner()
	result = runner.run(suite)
	sys.exit(not result.wasSuccessful())
Beispiel #27
0
def test_suite():
    from unittest import TestLoader
    return TestLoader().loadTestsFromName(__name__)
Beispiel #28
0
def test_suite():
    from unittest import TestLoader, TestSuite
    return TestSuite(
        [TestLoader().loadTestsFromName(__name__),
         make_integration_tests()])
Beispiel #29
0
def get_test_suite():
    test_loader = TestLoader()
    return test_loader.discover('test', pattern='*_test.py')
Beispiel #30
0
def suite():
    """ return all the tests"""
    return TestLoader().loadTestsFromTestCase(TestTesting)