Skip to content

Commit d1e03b7

Browse files
authored
Fix tests (#2015)
* Revert test cleanup * Try test_async without IsonlationLevel * Add guards to tests * Fix test_attrinjector
1 parent 24db38d commit d1e03b7

File tree

3 files changed

+7
-42
lines changed

3 files changed

+7
-42
lines changed

tests/IronPython.Tests/Cases/CommonCases.cs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6-
using System.IO;
76
using System.Threading;
87

98
using NUnit.Framework;
@@ -37,42 +36,6 @@ protected int TestImpl(TestInfo testcase) {
3736
return -1;
3837
} finally {
3938
m?.ReleaseMutex();
40-
CleanupTempFiles(testcase);
41-
}
42-
}
43-
44-
/// <summary>
45-
/// Removes @test_*_tmp files/directories left behind by test.support.TESTFN.
46-
/// </summary>
47-
private static void CleanupTempFiles(TestInfo testcase) {
48-
var testDir = Path.GetDirectoryName(testcase.Path);
49-
if (testDir is null) return;
50-
51-
// Clean test directory and also the StdLib test directory
52-
CleanupTempFilesInDir(testDir);
53-
var stdlibTestDir = Path.Combine(CaseExecuter.FindRoot(), "src", "core", "IronPython.StdLib", "lib", "test");
54-
if (stdlibTestDir != testDir) {
55-
CleanupTempFilesInDir(stdlibTestDir);
56-
}
57-
}
58-
59-
private static void CleanupTempFilesInDir(string dir) {
60-
if (!Directory.Exists(dir)) return;
61-
62-
try {
63-
foreach (var entry in Directory.EnumerateFileSystemEntries(dir, "@test_*_tmp*")) {
64-
try {
65-
if (File.GetAttributes(entry).HasFlag(FileAttributes.Directory)) {
66-
Directory.Delete(entry, recursive: true);
67-
} else {
68-
File.Delete(entry);
69-
}
70-
} catch {
71-
// ignore locked/in-use files
72-
}
73-
}
74-
} catch {
75-
// ignore enumeration errors
7639
}
7740
}
7841
}

tests/IronPython.Tests/Cases/IronPythonCasesManifest.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ WorkingDirectory=$(TEST_FILE_DIR)
44
Redirect=false
55
Timeout=120000 # 2 minute timeout
66

7-
[IronPython.test_async]
8-
IsolationLevel=PROCESS # loads IronPythonTest assembly, causes a failure in IronPython.test_attrinjector
9-
107
[IronPython.test_builtin_stdlib]
118
RunCondition=NOT $(IS_MONO)
129
Reason=Exception on adding DocTestSuite

tests/suite/test_async.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
import unittest
88

9-
from iptest import run_test
9+
from iptest import run_test, skipUnlessIronPython, is_netcoreapp
10+
from iptest.ipunittest import load_ironpython_test
1011

1112

1213
def run_coro(coro):
@@ -319,6 +320,7 @@ async def test():
319320
self.assertEqual(run_coro(test()), ['enter', 1, 2, 'exit'])
320321

321322

323+
@skipUnlessIronPython()
322324
class DotNetAsyncInteropTest(unittest.TestCase):
323325
"""Tests for .NET async interop (await Task, async for IAsyncEnumerable, CancelledError)."""
324326

@@ -423,6 +425,9 @@ def test_cancellation_token_cancel(self):
423425
cts.Cancel()
424426
self.assertTrue(token.IsCancellationRequested)
425427

428+
429+
@unittest.skipUnless(is_netcoreapp, "ValueTask is not available on .NET Framework")
430+
class ValueTaskInteropTest(unittest.TestCase):
426431
def test_await_valuetask(self):
427432
"""await a ValueTask (non-generic)."""
428433
from System.Threading.Tasks import ValueTask
@@ -464,8 +469,8 @@ async def test():
464469
import sys
465470
if sys.implementation.name == 'ironpython':
466471
import clr
472+
load_ironpython_test()
467473
try:
468-
clr.AddReference('IronPythonTest')
469474
from IronPythonTest import AsyncInteropHelpers
470475
_has_async_helpers = True
471476
except Exception:

0 commit comments

Comments
 (0)