FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JSON-DOC/python/conftest.py at main · textcortex/JSON-DOC · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
textcortex
/
JSON-DOC
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
6
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JSON-DOC
/
python
/
conftest.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
62 lines (45 loc) · 1.84 KB
Breadcrumbs
JSON-DOC
/
python
/
conftest.py
Copy path
File metadata and controls
62 lines (45 loc) · 1.84 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
import
os
import
sys
import
pytest
# This collects tests that aren't standard pytest tests
def
pytest_collect_file
(
parent
,
file_path
):
# Special handling for test_validation.py
if
file_path
.
name
==
"test_validation.py"
:
return
ValidationTestFile
.
from_parent
(
parent
,
path
=
file_path
)
return
None
class
ValidationTestFile
(
pytest
.
File
):
def
collect
(
self
):
# Create a special test item for test_validation.py
yield
ValidationTestItem
.
from_parent
(
self
,
name
=
"test_validation"
)
class
ValidationTestItem
(
pytest
.
Item
):
def
runtest
(
self
):
# Run the test_validation.py script with "schema" as the argument
import
subprocess
print
(
f"
\n
{
'-'
*
80
}
\n
Running test_validation.py with 'schema' argument..."
)
result
=
subprocess
.
run
(
[
sys
.
executable
,
str
(
self
.
fspath
),
"schema"
],
capture_output
=
True
,
text
=
True
,
)
# Always print the stdout for visibility
if
result
.
stdout
:
print
(
f"
\n
Output from test_validation.py:"
)
print
(
result
.
stdout
)
if
result
.
returncode
!=
0
:
raise
ValidationTestFailure
(
result
.
stdout
,
result
.
stderr
)
print
(
f"test_validation.py completed successfully.
\n
{
'-'
*
80
}
"
)
def
reportinfo
(
self
):
return
self
.
fspath
,
0
,
f"test_validation.py schema"
class
ValidationTestFailure
(
Exception
):
def
__init__
(
self
,
stdout
,
stderr
):
self
.
stdout
=
stdout
self
.
stderr
=
stderr
super
().
__init__
(
f"test_validation.py failed"
)
@
pytest
.
hookimpl
(
tryfirst
=
True
)
def
pytest_exception_interact
(
node
,
call
,
report
):
if
isinstance
(
call
.
excinfo
.
value
,
ValidationTestFailure
):
failure
=
call
.
excinfo
.
value
print
(
f"test_validation.py failed!"
)
if
failure
.
stderr
:
print
(
f"STDERR:
\n
{
failure
.
stderr
}
"
)
print
(
f"
{
'-'
*
80
}
"
)
Back
|
FazBrowse Home
|
New Git URL