File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ """Set of utilities for quality assurance of the grading script."""
2
+
3
+ from importlib import import_module
4
+
5
+
6
+ def import_as_non_testcase (module_name , name , package = None ):
7
+ """Import the name from a module and prevent pytest from running it as testcase."""
8
+ mod = import_module (module_name , package = package )
9
+ cls = mod .__dict__ [name ]
10
+ cls .__test__ = False
11
+ return cls
12
+
13
+
14
+ class SetupThenTearDown :
15
+ """Automatically call setUp and tearDown.
16
+
17
+ Intended to be used in the QA script.
18
+ """
19
+
20
+ def __init__ (self , obj ):
21
+ self .obj = obj
22
+
23
+ def __enter__ (self ):
24
+ if hasattr (self .obj , "setUp" ):
25
+ self .obj .setUp ()
26
+
27
+ def __exit__ (self , exc_type , exc_val , exc_tb ):
28
+ if hasattr (self .obj , "tearDown" ):
29
+ self .obj .tearDown ()
You can’t perform that action at this time.
0 commit comments