-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-allow changing flags in case someone needs that
- Loading branch information
Ben Creech
committed
Mar 9, 2024
1 parent
95f87cb
commit 70a2b22
Showing
3 changed files
with
60 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
from py_mini_racer import py_mini_racer | ||
|
||
DEFAULT_V8_FLAGS = py_mini_racer.DEFAULT_V8_FLAGS | ||
JSEvalException = py_mini_racer.JSEvalException | ||
JSFunction = py_mini_racer.JSFunction | ||
JSOOMException = py_mini_racer.JSOOMException | ||
JSObject = py_mini_racer.JSObject | ||
JSParseException = py_mini_racer.JSParseException | ||
JSSymbol = py_mini_racer.JSSymbol | ||
JSTimeoutException = py_mini_racer.JSTimeoutException | ||
LibAlreadyInitializedError = py_mini_racer.LibAlreadyInitializedError | ||
LibNotFoundError = py_mini_racer.LibNotFoundError | ||
MiniRacer = py_mini_racer.MiniRacer | ||
StrictMiniRacer = py_mini_racer.StrictMiniRacer | ||
init_mini_racer = py_mini_racer.init_mini_racer | ||
|
||
|
||
__all__ = ["py_mini_racer", "MiniRacer"] |
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,24 @@ | ||
import pytest | ||
|
||
from py_mini_racer import LibAlreadyInitializedError, init_mini_racer | ||
|
||
|
||
def test_init(): | ||
init_mini_racer(ignore_duplicate_init=True) | ||
|
||
with pytest.raises(LibAlreadyInitializedError): | ||
init_mini_racer() | ||
|
||
init_mini_racer(ignore_duplicate_init=True) | ||
|
||
|
||
# Unfortunately while init_mini_racer allows changing V8 flags, it's hard to test | ||
# automatically because only the first use of V8 can set flags. We'd need to | ||
# restart Python between tests. | ||
# Here's a manual test: | ||
# def test_init_flags(): | ||
# from py_mini_racer import DEFAULT_V8_FLAGS, MiniRacer, init_mini_racer | ||
# init_mini_racer(flags=(*DEFAULT_V8_FLAGS, '--no-use-strict')) | ||
# mr = MiniRacer() | ||
# # this would normally fail in strict JS mode because foo is not declared: | ||
# mr.eval('foo = 4') |