We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 57741c2 commit 7dfc0a5Copy full SHA for 7dfc0a5
tests/texampleTests.m
@@ -6,11 +6,17 @@
6
methods (TestClassSetup)
7
function setUpAndTearDowns(testCase)
8
openAIEnvVar = "OPENAI_KEY";
9
- key = getenv(openAIEnvVar);
10
- writelines("OPENAI_API_KEY="+key,".env");
+ secretKey = getenv(openAIEnvVar);
+ % Create an empty .env file because it is expected by our .mlx
11
+ % example files
12
+ writelines("",".env");
13
+
14
+ % Assign the value of the secret key to OPENAI_API_KEY using
15
+ % the test fixture
16
+ import matlab.unittest.fixtures.EnvironmentVariableFixture
17
+ fixture = EnvironmentVariableFixture("OPENAI_API_KEY", secretKey);
18
+ testCase.applyFixture(fixture);
19
- testCase.addTeardown(@() delete(".env"));
- testCase.addTeardown(@() unsetenv("OPENAI_API_KEY"));
20
testCase.addTeardown(@() iCloseAll());
21
end
22
0 commit comments