forked from f3d-app/f3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expose log levels in Python bindings (f3d-app#1417)
* expose log levels in Python bindings * CI formatting * make tests cross-platform * disable `F3D_WINDOWS_GUI`
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import subprocess | ||
import sys | ||
|
||
|
||
def test_default_level(): | ||
assert ( | ||
run_python( | ||
"from f3d import Log", | ||
"Log.set_use_coloring(False)", | ||
"Log.print(Log.DEBUG, 'debug')", | ||
"Log.print(Log.INFO, 'info')", | ||
) | ||
== "info\n" | ||
) | ||
|
||
|
||
def test_debug(): | ||
assert ( | ||
run_python( | ||
"from f3d import Log", | ||
"Log.set_use_coloring(False)", | ||
"Log.set_verbose_level(Log.DEBUG)", | ||
"Log.print(Log.DEBUG, 'debug')", | ||
) | ||
== "debug\n" | ||
) | ||
|
||
|
||
def test_coloring(): | ||
assert ( | ||
run_python( | ||
"from f3d import Log", | ||
"Log.set_use_coloring(True)", | ||
"Log.print(Log.INFO, 'info')", | ||
) | ||
== "info\x1b[0m\n" | ||
) | ||
|
||
|
||
def run_python(*statements: str): | ||
return subprocess.check_output( | ||
[sys.executable, "-c", "; ".join(statements)], | ||
text=True, | ||
) |