File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
def decorator_func (func ):
6
6
def wrapper (* args , ** kwargs ):
7
- if 7 <= datetime .now ().hour < 16 :
8
- func (* args , ** kwargs )
7
+ if 7 <= datetime .now ().hour < 18 :
8
+ #func(*args, **kwargs)
9
+ return func (* args ,** kwargs )
9
10
else :
10
11
pass # Hush, the neighbors are asleep
11
12
return wrapper
Original file line number Diff line number Diff line change 1
1
##Illustrating the decorator call with arguments concept
2
2
# Example 1
3
3
from decorator import decorator_func
4
+ import pytest
4
5
5
6
@decorator_func
6
7
def dec_call3 (name ):
7
8
print (f"Hi this is the diff file call by { name } " )
8
9
10
+ @decorator_func
11
+ def dec_call4 (name ):
12
+ print (f"Hi this is the diff file second call by { name } . Returning YAY" )
13
+ return "YAY"
14
+
15
+
9
16
dec_call3 ("Abhiram" )
17
+ ret_val = dec_call4 ("Kratos" )
18
+ print ("Ret val = " + str (ret_val ))
19
+
20
+ try :
21
+ assert ret_val == None
22
+ except :
23
+ assert ret_val == "YAY"
You can’t perform that action at this time.
0 commit comments