FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/python_tests_runner/PythonTestRunner.cs at net10 · losttech/pythonnet · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
losttech
/
pythonnet
Public
forked from
pythonnet/pythonnet
Notifications
You must be signed in to change notification settings
Fork
1
Star
2
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
src
/
python_tests_runner
/
PythonTestRunner.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
67 lines (58 loc) · 2.08 KB
Breadcrumbs
pythonnet
/
src
/
python_tests_runner
/
PythonTestRunner.cs
Copy path
File metadata and controls
67 lines (58 loc) · 2.08 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
IO
;
using
System
.
Linq
;
using
System
.
Reflection
;
using
System
.
Text
;
using
NUnit
.
Framework
;
using
Python
.
Runtime
;
namespace
Python
.
PythonTestsRunner
{
public
class
PythonTestRunner
{
string
OriginalDirectory
;
[
OneTimeSetUp
]
public
void
SetUp
(
)
{
PythonEngine
.
Initialize
(
)
;
OriginalDirectory
=
Environment
.
CurrentDirectory
;
var
codeDir
=
File
.
ReadAllText
(
"tests_location.txt"
)
.
Trim
(
)
;
TestContext
.
Progress
.
WriteLine
(
$
"Changing working directory to
{
codeDir
}
"
)
;
Environment
.
CurrentDirectory
=
codeDir
;
}
[
OneTimeTearDown
]
public
void
Dispose
(
)
{
PythonEngine
.
Shutdown
(
)
;
Environment
.
CurrentDirectory
=
OriginalDirectory
;
}
/// <summary>
/// Selects the Python tests to be run as embedded tests.
/// </summary>
/// <returns></returns>
static
IEnumerable
<
string
[
]
>
PythonTestCases
(
)
{
// Add the test that you want to debug here.
yield
return
new
[
]
{
"test_indexer"
,
"test_boolean_indexer"
}
;
yield
return
new
[
]
{
"test_delegate"
,
"test_bool_delegate"
}
;
yield
return
new
[
]
{
"test_subclass"
,
"test_implement_interface_and_class"
}
;
}
/// <summary>
/// Runs a test in src/tests/*.py as an embedded test. This facilitates debugging.
/// </summary>
/// <param name="testFile">The file name without extension</param>
/// <param name="testName">The name of the test method</param>
[
TestCaseSource
(
nameof
(
PythonTestCases
)
)
]
public
void
RunPythonTest
(
string
testFile
,
string
testName
)
{
using
dynamic
pytest
=
Py
.
Import
(
"pytest"
)
;
using
var
args
=
new
PyList
(
)
;
args
.
Append
(
new
PyString
(
$
"
{
testFile
}
.py::
{
testName
}
"
)
)
;
int
res
=
pytest
.
main
(
args
)
;
if
(
res
!=
0
)
{
Assert
.
Fail
(
$
"Python test
{
testFile
}
.
{
testName
}
failed"
)
;
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL