FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ArchUnitPython/src/archunitpython/testing/assertion.py at main · freud14/ArchUnitPython · GitHub
freud14
/
ArchUnitPython
Public
forked from
LukasNiessen/ArchUnitPython
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ArchUnitPython
/
src
/
archunitpython
/
testing
/
assertion.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
47 lines (35 loc) · 1.4 KB
Breadcrumbs
ArchUnitPython
/
src
/
archunitpython
/
testing
/
assertion.py
Copy path
File metadata and controls
47 lines (35 loc) · 1.4 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
"""Testing assertion helpers for architecture rules."""
from
__future__
import
annotations
from
archunitpython
.
common
.
assertion
.
violation
import
Violation
from
archunitpython
.
common
.
fluentapi
.
checkable
import
Checkable
,
CheckOptions
from
archunitpython
.
testing
.
common
.
violation_factory
import
ViolationFactory
def
format_violations
(
violations
:
list
[
Violation
])
->
str
:
"""Format violations into a human-readable string.
Args:
violations: List of violations to format.
Returns:
Formatted string describing all violations.
"""
if
not
violations
:
return
"No violations found."
lines
=
[
f"Found
{
len
(
violations
)
}
architecture violation(s):"
,
""
]
for
i
,
violation
in
enumerate
(
violations
,
1
):
tv
=
ViolationFactory
.
from_violation
(
violation
)
lines
.
append
(
f"
{
i
}
.
{
tv
.
message
}
"
)
lines
.
append
(
f"
{
tv
.
details
}
"
)
lines
.
append
(
""
)
return
"
\n
"
.
join
(
lines
)
def
assert_passes
(
checkable
:
Checkable
,
options
:
CheckOptions
|
None
=
None
,
)
->
None
:
"""Assert that an architecture rule passes (no violations).
Args:
checkable: Any object with a check() method (implements Checkable).
options: Optional check options.
Raises:
AssertionError: If the rule has violations.
"""
violations
=
checkable
.
check
(
options
)
if
violations
:
raise
AssertionError
(
format_violations
(
violations
))
Back
|
FazBrowse Home
|
New Git URL