How to use unittest2 - 10 common examples

To help you get started, we’ve selected a few unittest2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github giampaolo / psutil / test / View on Github external
    @unittest.skipUnless(hasattr(psutil.Process, "environ"),
                         "environ not available")
    @unittest.skipUnless(POSIX, "posix only")
    def test_weird_environ(self):
        # environment variables can contain values without an equals sign
        code = textwrap.dedent("""
        char * const argv[] = {"cat", 0};
        char * const envp[] = {"A=1", "X", "C=3", 0};
        int main(void) {
            /* Close stderr on exec so parent can wait for the execve to
             * finish. */
            if (fcntl(2, F_SETFD, FD_CLOEXEC) != 0)
                return 0;
            return execve("/bin/cat", argv, envp);
github dexonline / dexonline / tools / functests / View on Github external
# This prints a bunch of text/password controls, but only ONE CheckboxControl
def edit_account(br, nick, password, new_password, new_password2, name, email, design, pref_st): + '/preferinte').read()
    if nick: br['nick'] = nick
    if password: br['curPass'] = password
    if new_password: br['newPass'] = new_password
    if new_password2: br['newPass2'] = new_password2
    if name: br['name'] = name
    if email: br['email'] = email
    if design: br['skin'] = [design]
    if pref_st is not None: br.find_control('userPrefs[]').items[0].selected = pref_st
    resp = br.submit()
    return resp

class LoginTest(unittest.TestCase):

    def test_register_bad_info(self):
        br = mechanize.Browser()
        resp = create_account(br, '', '', '')
        html =
        self.assertIn('Trebuie să vă alegeți un nume de cont', html)

        resp = create_account(br, 'john', '', '')
        html =
        self.assertIn('Trebuie să vă alegeți o parolă', html)

        resp = create_account(br, 'john', '', 'password', 'mismatched password')
        html =
        self.assertIn('Parolele nu coincid', html)

        resp = create_account(br, 'vasile', '', 'password')
github databricks / spark-sklearn / python / pdspark / View on Github external
.addGrid(lasso.regParam, [0.001, 0.005, 0.01]) \

        evaluator = RegressionEvaluator(labelCol="rating", metricName="r2")

        cv = CrossValidator(estimator=pipeline, evaluator=evaluator, estimatorParamMaps=paramGrid)

        cvModel =

        test ="json").load(trainFilepath)
        r2 = evaluator.evaluate(cvModel.transform(test))
        print "Test data R^2 score: %g" % r2

if __name__ == "__main__":
github apple / swift-lldb / test / tools / lldb-server / View on Github external

    def test_P_and_p_thread_suffix_work_llgs_dwarf(self):

if __name__ == '__main__':
github wireservice / agate / tests / View on Github external
    @unittest.skipIf(six.PY3, 'Not supported in Python 3.')
    def test_cast_long(self):
        self.assertEqual(self.type.test(long('141414')), True)
        self.assertEqual(self.type.cast(long('141414')), Decimal('141414'))
github quattor / aquilon / tests / broker / View on Github external
self.wait_notification(basetime, 0)

    def testverifyall(self):
        command = ["show_metacluster", "--all"]
        out = self.commandtest(command)
        self.matchclean(out, "Metacluster: utmc", command)

    def testdelnotfound(self):
        command = ["del_metacluster",

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestDelMetaCluster)
github timlau / FedoraReview / test / View on Github external
if fr_testcase.NO_NET:
    print "Warning:  No network available, only some tests run"
if not 'REVIEW_LOGLEVEL' in os.environ:
    print "Warning:  REVIEW_LOGLEVEL not set, lot's of output ahead."
if fr_testcase.FAST_TEST:
    print "Warning: slow tests skipped"


testFail = 0
for t in 'Misc', 'Bugzilla', 'Ext', 'Options', 'Checks', 'RChecks', \
         'Regressions', 'Dist', 'Deps':
    test = eval('unittest.TestLoader().loadTestsFromTestCase(Test%s)' % t)
    result = unittest.TextTestRunner(verbosity=VERBOSITY).run(test)
    testFail = testFail + len(result.errors) + len(result.failures)

github qubole / spark-on-lambda / python / pyspark / streaming / View on Github external
% kinesis_asl_assembly_dir) +
            "You need to build Spark with 'build/sbt -Pkinesis-asl "
            "assembly/package streaming-kinesis-asl-assembly/assembly'"
            "or 'build/mvn -Pkinesis-asl package' before running this test.")

    sys.stderr.write("Running tests: %s \n" % (str(testcases)))
    failed = False
    for testcase in testcases:
        sys.stderr.write("[Running %s]\n" % (testcase))
        tests = unittest.TestLoader().loadTestsFromTestCase(testcase)
        if xmlrunner:
            result = xmlrunner.XMLTestRunner(output='target/test-reports', verbosity=3).run(tests)
            if not result.wasSuccessful():
                failed = True
            result = unittest.TextTestRunner(verbosity=3).run(tests)
            if not result.wasSuccessful():
                failed = True
github quattor / aquilon / tests / broker / View on Github external
"--osname=utos", "--osversion=1.0"]

    def testverifydelos(self):
        command = "show os --osname utos --archetype=utarchetype1"
        self.notfoundtest(command.split(" "))

    def testdelinvalid(self):
        command = ["del_os", "--archetype=utarchetype1",
                   "--osname=os-does-not-exist", "--osvers=1.0"]

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestDelOS)
github quattor / aquilon / tests / broker / View on Github external
def test_450_verify_positions(self):
        command = ["search", "dns", "domain", "map", "--room", "utroom1"]
        out = self.commandtest(command)
                          r"DNS Domain: Map: Room utroom1\s*"
                          r"Position: 0\s*"
                          r"DNS Domain: Map: Room utroom1\s*"
                          r"Position: 1\s*"
                          r"DNS Domain: Map: Room utroom1\s*"
                          r"Position: 2\s*",

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestMapDnsDomain)