Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automating unittest
#4
I have mako both on 2.7 and 3.5 on my computer (from ubuntu repositories).

You can also do it with the standard library, but it is less robust or extensible
body = '\n'.join(
"""\
    def {}(self):
        '''Test addition of {}'''
        self.assertEqual({}, {} + {})\
""".format(name, description, result, left, right)
for name, left, right, result, description in testlist)
classcode = 'class AddTest(unittest.TestCase):\n' + body
exec(classcode)
print(classcode)
print(AddTest)
Reply


Messages In This Thread
Automating unittest - by ichabod801 - Oct-28-2018, 08:39 PM
RE: Automating unittest - by Gribouillis - Oct-28-2018, 09:07 PM
RE: Automating unittest - by ichabod801 - Oct-28-2018, 09:19 PM
RE: Automating unittest - by Gribouillis - Oct-28-2018, 09:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem in using unittest akbarza 2 316 Feb-25-2024, 12:51 PM
Last Post: deanhystad
Question Is there a python program for automating this invoicing workflow? PG_Archipelago 3 1,086 Feb-02-2023, 11:01 PM
Last Post: Larz60+
Question Unwanted execution of unittest ThomasFab 9 2,065 Nov-15-2022, 05:33 PM
Last Post: snippsat
  unittest.mock for an api key silver 3 1,396 Aug-29-2022, 03:52 PM
Last Post: ndc85430
  Ran 0 tests in 0.000s - unittest Peaches 8 5,114 Dec-31-2021, 08:58 AM
Last Post: Peaches
  Help with Creating a Script for Automating Reports SunWers 1 1,928 Dec-29-2020, 10:21 PM
Last Post: jjc385
  Automating to run python script 100 times by changing parameters pmt 1 2,609 Dec-29-2020, 10:31 AM
Last Post: andydoc
Sad Problem with Unittest mhanusek 1 3,767 Nov-12-2020, 04:58 PM
Last Post: Gribouillis
  Unittest et patch mad31 2 2,134 Aug-09-2020, 06:16 AM
Last Post: mad31
  Unusual things to do with unittest/HTMLTestRunner AndyHolyer 0 2,146 Jul-29-2020, 02:43 PM
Last Post: AndyHolyer

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020