@@ -28,7 +28,7 @@ public void setUp() {
28
28
public void tearDown () {
29
29
Cleaner .INSTANCE .doCleaning ();
30
30
}
31
- private File loadExampleCode (String name ) {
31
+ private File loadResource (String name ) {
32
32
URL resource = getClass ().getClassLoader ().getResource (name );
33
33
if (resource == null ) {
34
34
throw new IllegalArgumentException ("file not found!" );
@@ -43,7 +43,7 @@ private File loadExampleCode(String name) {
43
43
44
44
@ Test
45
45
public void testSimpleFunction () {
46
- File fileWithCode = loadExampleCode ("example_code/arithmetic.py" );
46
+ File fileWithCode = loadResource ("example_code/arithmetic.py" );
47
47
String pythonRunRoot = fileWithCode .getParentFile ().getAbsolutePath ();
48
48
String moduleFilename = fileWithCode .getAbsolutePath ();
49
49
PythonObjectName testMethodName = new PythonObjectName ("arithmetic" , "calculate_function_value" );
@@ -66,7 +66,7 @@ public void testSimpleFunction() {
66
66
67
67
@ Test
68
68
public void testSimpleFunctionTestCase () {
69
- File fileWithCode = loadExampleCode ("example_code/arithmetic.py" );
69
+ File fileWithCode = loadResource ("example_code/arithmetic.py" );
70
70
String pythonRunRoot = fileWithCode .getParentFile ().getAbsolutePath ();
71
71
String moduleFilename = fileWithCode .getAbsolutePath ();
72
72
PythonObjectName testMethodName = new PythonObjectName ("arithmetic" , "calculate_function_value" );
@@ -86,4 +86,29 @@ public void testSimpleFunctionTestCase() {
86
86
Assertions .assertTrue (testCase .size () > 0 );
87
87
Assertions .assertTrue (testCase .get (0 ).component2 ().size () > 0 );
88
88
}
89
+
90
+ @ Test
91
+ public void testSimpleClassMethod () {
92
+ File fileWithCode = loadResource ("example_code/inner_dir/inner_module.py" );
93
+ File projectRoot = loadResource ("example_code/" );
94
+ String pythonRunRoot = projectRoot .getAbsolutePath ();
95
+ String moduleFilename = fileWithCode .getAbsolutePath ();
96
+ PythonObjectName containingClassName = new PythonObjectName ("inner_dir.inner_module" , "InnerClass" );
97
+ PythonObjectName testMethodName = new PythonObjectName ("inner_dir.inner_module" , "f" );
98
+ PythonTestMethodInfo methodInfo = new PythonTestMethodInfo (testMethodName , moduleFilename , containingClassName );
99
+ ArrayList <PythonTestMethodInfo > testMethods = new ArrayList <>(1 );
100
+ testMethods .add (methodInfo );
101
+ ArrayList <String > directoriesForSysPath = new ArrayList <>();
102
+ directoriesForSysPath .add (pythonRunRoot );
103
+ String testCode = PythonUtBotJavaApi .generate (
104
+ testMethods ,
105
+ pythonPath ,
106
+ pythonRunRoot ,
107
+ directoriesForSysPath ,
108
+ 10_000 ,
109
+ 1_000 ,
110
+ Unittest .INSTANCE
111
+ );
112
+ Assertions .assertTrue (testCode .length () > 0 );
113
+ }
89
114
}
0 commit comments