示例#1
0
def main():
    from distutils.dist import Distribution
    from optparse import OptionParser

    parser = OptionParser(usage='usage: %prog [options] test_suite ...',
                          version='%%prog %s' % VERSION)
    parser.add_option('-o', '--xml-output', action='store', dest='xml_output',
                      metavar='FILE', help='write XML test results to FILE')
    parser.add_option('-d', '--coverage-dir', action='store',
                      dest='coverage_dir', metavar='DIR',
                      help='store coverage results in DIR')
    parser.add_option('-s', '--coverage-summary', action='store',
                      dest='coverage_summary', metavar='FILE',
                      help='write coverage summary to FILE')
    options, args = parser.parse_args()
    if len(args) < 1:
        parser.error('incorrect number of arguments')

    cmd = unittest(Distribution())
    cmd.initialize_options()
    cmd.test_suite = args[0]
    if hasattr(options, 'xml_output'):
        cmd.xml_output = options.xml_output
    if hasattr(options, 'coverage_summary'):
        cmd.coverage_summary = options.coverage_summary
    if hasattr(options, 'coverage_dir'):
        cmd.coverage_dir = options.coverage_dir
    cmd.finalize_options()
    cmd.run()
示例#2
0
def main(
    argv: typing.List[str],
    program: str,
    unittest,
    do_work,
    out_log='out_log',
):
    config = shared_configuration.make(
        program=program,
        argv=argv[1:],
    )
    print('started %s with configuration' % program)
    print(str(config))
    # echo print statement to the log file
    sys.stdout = Logger(config.get(out_log))
    print(str(config))
    if config.get('debug', False):
        # enter pdb if run-time error
        # (useful during development)
        import debug
        if False:
            debug.info
    unittest(config)
    do_work(config)
示例#3
0
def main():
    from distutils.dist import Distribution
    from optparse import OptionParser

    parser = OptionParser(usage='usage: %prog [options] test_suite ...',
                          version='%%prog %s' % VERSION)
    parser.add_option('-o',
                      '--xml-output',
                      action='store',
                      dest='xml_output',
                      metavar='FILE',
                      help='write XML test results to FILE')
    parser.add_option('-d',
                      '--coverage-dir',
                      action='store',
                      dest='coverage_dir',
                      metavar='DIR',
                      help='store coverage results in DIR')
    parser.add_option('-s',
                      '--coverage-summary',
                      action='store',
                      dest='coverage_summary',
                      metavar='FILE',
                      help='write coverage summary to FILE')
    options, args = parser.parse_args()
    if len(args) < 1:
        parser.error('incorrect number of arguments')

    cmd = unittest(Distribution())
    cmd.initialize_options()
    cmd.test_suite = args[0]
    if hasattr(options, 'xml_output'):
        cmd.xml_output = options.xml_output
    if hasattr(options, 'coverage_summary'):
        cmd.coverage_summary = options.coverage_summary
    if hasattr(options, 'coverage_dir'):
        cmd.coverage_dir = options.coverage_dir
    cmd.finalize_options()
    cmd.run()
示例#4
0
 def test_5(self):
   self.assertEqual(unittest(5), 'Buzz')
示例#5
0
 def test_15(self):
   self.assertEqual(unittest(15), 'FizzBuzz')
示例#6
0
 def test_7(self):
   self.assertEqual(unittest(7), 7)
示例#7
0
 def test_3(self):
   self.assertEqual(unittest(3), 'Fizz')
示例#8
0
        self.fail()

    @unittest.expectedFailure
    def test_sign_proposal(self):
        # TODO impl
        # signing_identity = None
        # proposal = build_proposal()
        # signed_proposal = sign_proposal(signing_identity, proposal)
        self.fail()

    @unittest.expectedFailure
    def test_sign_tran_payload(self):
        # TODO impl
        # signing_identity = None
        # tran_payload = None
        # envelope = sign_tran_payload(signing_identity, tran_payload)
        self.fail()

    @unittest.expectedFailure
    def test_create_transaction_request(self):
        # TODO impl
        # responses = None
        # proposal = None
        # header = None
        # request = TransactionRequest(responses, proposal, header)
        self.fail()


if __name__ == '__main__':
    unittest()
import unittest

from money_tracker import extract_date

class MoneyTrackerTests(unittest.TestCase):
    def test_extract_date_value(self):
        with self.assertRaises(ValueError):
            extract_date("=== 12.03-2012 ===")
    def test_extract_date_result(self):
            self.assertEquals(extract_date("=== 12-03-2018 ==="), 2018312);
    #checks whether the date is valid.
    def test_show_user_by_date_Value(self):
        with self.assertRaises(ValueError):
            show_user_data_by_date("a2-03-2018")
            show_user_data_by_date("01-01-2019")

    def test_show_user_data_by_date_result(self):
        assertEquals(show_user_data_by_date("22-03-2018"),);


if __name__ == "__main__":
    unittest().main()
        tests that the friend_to_remove() functions returns the friend with the given name and age that the user wants to remove
        returns true if the friend_to_remove function works as it should
        """
        friendToRemove = Network.friend_to_remove(self, "Vanessa", 18)
        #checks that the Person returned by the friend_to_remove() function contains that name and age
        self.assertEqual(friendToRemove.get_name(), "Vanessa")
        
    def test_remove_friend(self):
        """
        Tests that the remove_friend() function removes the specified person to the set
        Takes a Person, friendToRemove and returns True if the specified friend was removed from the set or False if it wasn't
        """
        friendToRemove = Network.friend_to_remove(self, "Vanessa", 18)
        
        Network.remove_friend(self, friendToRemove)
        #check that the friend was removed from the set
        self.assertTrue(friendToRemove is not Network.setOfFriends)
        
    def test_remove_all_friends(self):
        """
        tests that remove_all_friends() removes all of the friends from the set
        returns True if all of the friends were removed from the set and false if they weren't
        """
        Network.remove_all_friends(self)
        #if the set is empty
        self.assertTrue(not Network.setOfFriends)
        
#calls unittest
if __name__ == "__main__":
    unittest()      
import unittest
import karakterbog


class unittest(unittest.TestCase):

    def testgetInput(self):
        self.assertIsInstance(user, str)


    def testsetUserVars(self):
        self.assertIsInstance(alias, str)
        self.assertIsInstance(enemy, str)
        self.assertIsInstance(greeting, str)


    #def greetUser():


a = unittest()
a.testsetUserVars()
#date:  2019/10/5
# -*- coding: UTF-8 -*-

from selenium import webdriver
from ddt import ddt, data, unpack
import unittest

@ddt
class searchddt(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(30)
        self.driver.maximize_window()

        self.driver.get("https://www.baidu.com")

    @data('selenium', 'loadrunner', 'jmeter')
    @unpack
    def test_search(self, search_value):
        self.search_field = self.driver.find_element_by_id('kw')
        self.search_field.clear()
        self.search_field.send_keys(search_value)
        self.search_field.submit()


    def tearDown(self):
        self.driver.quit()

if __name__ == '__main__':
    unittest(webdriver=2)
示例#13
0
    def test_yield_longest2(self):
        big = (1, 7)
        small = (6, 8)
        first, second = prune_matches.yield_longest(big, small)
        self.assertEqual(second, (8, 8))

    def test_remove_nesting1(self):
        # Half nested overlap
        data = [(2, 3), (2, 8)]
        answer = [(2, 8)]
        result = prune_matches.remove_nesting(data)
        self.assertEqual(result, answer)

    def test_remove_nesting2(self):
        # When frist span is contained within second span - removes the first.
        data = [(1, 2), (0, 3)]
        answer = [(0, 3)]
        result = prune_matches.remove_nesting(data)
        self.assertEqual(result, answer)

    def test_remove_nesting3(self):
        # Multiple concentric nesting.
        data = [(2, 3), (1, 4), (0, 5)]
        answer = [(0, 5)]
        result = prune_matches.remove_nesting(data)
        self.assertEqual(result, answer)


if __name__ == '__main__':
    unittest(main)
示例#14
0
from fizzbuzz import Fizzbuzz


class fizzbuzzTest(unittest.TestCase):
    def test_non_list_inputs(self):
        self.assertEqual(Fizzbuzz(5, 8), "Invalid input")

    def test_non_list_input(self):
        self.assertEqual(Fizzbuzz([2, 3, 4], 7), "Invalid input")

    def test_fizz(self):
        self.assertEqual(Fizzbuzz([1, 3, 4], ['a', 'b', 'c']), "fizz")

    def test_buzz(self):
        self.assertEqual(Fizzbuzz([4, 5, 4], [3, 4]), "buzz")

    def test_fizz_buzz(self):
        self.assertEqual(
            Fizzbuzz([1, 2, 3, 3, 4, 5, 5, 5, 5, 6], [7, 7, 4, 5, 9]),
            "Fizzbuzz")

    def test_other_total(self):
        self.assertEqual(Fizzbuzz([4, 5, 6], [3]), 4)

    def test_both_empty(self):
        self.assertEqual(Fizzbuzz([1, 3, 5], []), "fizz")


if __name__ == '__main__':
    unittest().run()
示例#15
0
def suite():  # 创建一个TestSuite
    suite = unittest(TestExample, 'test')
    return suite
示例#16
0
def main():
    unittest()