Skip to content

Commit 94e5a5e

Browse files
committed
SONARPY-2019 Fix NPE for workDir in IPynbSensorTest (#1876)
1 parent c22ec01 commit 94e5a5e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sonar-python-plugin/src/test/java/org/sonar/plugins/python/IPynbSensorTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
package org.sonar.plugins.python;
2121

2222
import java.io.File;
23+
import java.io.IOException;
24+
import java.nio.file.Files;
2325
import java.util.Collections;
2426
import java.util.List;
2527
import org.junit.jupiter.api.BeforeEach;
@@ -67,7 +69,7 @@ class IPynbSensorTest {
6769
private static final String FILE_1 = "file1.ipynb";
6870
private static final String NOTEBOOK_FILE = "notebook.ipynb";
6971

70-
private final File baseDir = new File("src/test/resources/org/sonar/plugins/python/ipynb").getAbsoluteFile();
72+
private final File baseDir = new File("src/test/resources/org/sonar/plugins/python/ipynb/").getAbsoluteFile();
7173

7274
private SensorContextTester context;
7375

@@ -77,8 +79,10 @@ class IPynbSensorTest {
7779
public LogTesterJUnit5 logTester = new LogTesterJUnit5().setLevel(Level.DEBUG);
7880

7981
@BeforeEach
80-
void init() {
82+
void init() throws IOException {
8183
context = SensorContextTester.create(baseDir);
84+
var workDir = Files.createTempDirectory("workDir");
85+
context.fileSystem().setWorkDir(workDir);
8286
}
8387

8488
@Test

0 commit comments

Comments
 (0)