Python Forum
unittest for nested function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unittest for nested function
#1
Hello all,

Have to write couple unittests for nested function.
This is simplified version

def processSubscription(
        self,
        command,
        **conditions
):
    def _matchConditions(request_conditions, command_conditions):
        if request_conditions in command_conditions:
            return True
        else
            return False

    if _matchConditions(conditions, command_conditions):
        subscribers = subscription['emails']
        send_mail(subscribers)

I want to capture the return value from _matchConditions
for my tests and also mock send_mail function,
so mails are not actually send on match.
Reply


Messages In This Thread
unittest for nested function - by fstefanov - Oct-15-2018, 09:47 AM
RE: unittest for nested function - by ichabod801 - Oct-15-2018, 01:35 PM
RE: unittest for nested function - by jdjeffers - Oct-15-2018, 01:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem in using unittest akbarza 2 358 Feb-25-2024, 12:51 PM
Last Post: deanhystad
  nested function return MHGhonaim 2 644 Oct-02-2023, 09:21 AM
Last Post: deanhystad
Question Unwanted execution of unittest ThomasFab 9 2,130 Nov-15-2022, 05:33 PM
Last Post: snippsat
  unittest.mock for an api key silver 3 1,415 Aug-29-2022, 03:52 PM
Last Post: ndc85430
  return vs. print in nested function example Mark17 4 1,793 Jan-04-2022, 06:02 PM
Last Post: jefsummers
  Ran 0 tests in 0.000s - unittest Peaches 8 5,220 Dec-31-2021, 08:58 AM
Last Post: Peaches
  Exit function from nested function based on user input Turtle 5 2,955 Oct-10-2021, 12:55 AM
Last Post: Turtle
Question Stopping a parent function from a nested function? wallgraffiti 1 3,710 May-02-2021, 12:21 PM
Last Post: Gribouillis
Sad Problem with Unittest mhanusek 1 3,810 Nov-12-2020, 04:58 PM
Last Post: Gribouillis
  Nested function problem chipx 8 3,559 Oct-21-2020, 11:56 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

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