File tree Expand file tree Collapse file tree 4 files changed +23
-3
lines changed
Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -337,3 +337,4 @@ $RECYCLE.BIN/
337337# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
338338
339339.vscode /
340+ localstuff /
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ Decorate your unittest class with `@perf_unit_test_class` to turn standard unit
2929from perf_unit import perf_unit_test_class
3030import unittest
3131
32- @perf_unit_test_class ()
32+ @perf_unit_test_class
3333class MyTestCase (unittest .TestCase ):
3434
3535 def test_example1 (self ):
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ def run_single_iteration(
6161
6262
6363def perf_unit_test_class (
64+ * args ,
6465 how_many_threads : int = 30 ,
6566 total_number_of_method_executions : int = 100 ,
6667 upper_median_threashold_in_milliseconds : int = 500 ,
@@ -91,7 +92,7 @@ def wrapped_method(*args, **kwargs):
9192 )
9293 )
9394
94- execution_times = [future .result () for future in futures ]
95+ execution_times = tuple ( [future .result () for future in futures ])
9596
9697 median_time = statistics .median (execution_times )
9798
@@ -121,4 +122,7 @@ def wrapped_method(*args, **kwargs):
121122
122123 return cls
123124
125+ if len (args ) == 1 :
126+ return modify_test_class (args [0 ])
127+
124128 return modify_test_class
Original file line number Diff line number Diff line change @@ -21,7 +21,9 @@ def test_method(false_self):
2121 self .assertTrue (result .wasSuccessful ())
2222
2323 def test_should_fail_due_too_high_latency (self ):
24- @perf_unit_test_class (how_many_threads = 50 , upper_median_threashold_in_milliseconds = 1 )
24+ @perf_unit_test_class (
25+ how_many_threads = 50 , upper_median_threashold_in_milliseconds = 1
26+ )
2527 class SomeTestClass (TestCase ):
2628 def test_method (false_self ):
2729 time .sleep (random .randint (200 , 600 ) / 1000 )
@@ -50,6 +52,19 @@ def test_class_has_no_test_methods(self):
5052 class SomeTestClass (TestCase ):
5153 pass
5254
55+ def test_decorators_with_no_inputs (self ):
56+ @perf_unit_test_class
57+ class SomeTestClass (TestCase ):
58+ def test_method (false_self ):
59+ pass
60+
61+ suite = TestLoader ().loadTestsFromTestCase (SomeTestClass )
62+
63+ runner = TextTestRunner ()
64+ result = runner .run (suite )
65+ result .printErrors ()
66+ self .assertTrue (result .wasSuccessful ())
67+
5368
5469if __name__ == "__main__" :
5570 main ()
You can’t perform that action at this time.
0 commit comments