Skip to content

Commit aad5dce

Browse files
committed
Merge branch 'update-settings-test'
2 parents 54dab81 + 99a0bf7 commit aad5dce

File tree

3 files changed

+51
-14
lines changed

3 files changed

+51
-14
lines changed

mathicsscript/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,14 @@
66
"""
77
from mathicsscript.version import __version__
88

9-
__all__ = [__version__]
9+
10+
def load_default_settings_files(definitions):
11+
import os.path as osp
12+
from mathics.core.definitions import autoload_files
13+
14+
root_dir = osp.realpath(osp.dirname(__file__))
15+
16+
autoload_files(definitions, root_dir, "autoload")
17+
18+
19+
__all__ = [__version__, load_default_settings_files]

mathicsscript/completion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def get_completions(
103103
words = []
104104

105105
def word_matches(word: str) -> bool:
106-
""" True when the word before the cursor matches. """
106+
"""True when the word before the cursor matches."""
107107

108108
if self.match_middle:
109109
return word_before_cursor in word

test/test_settings.py

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,44 @@
11
# -*- coding: utf-8 -*-
22
from .helper import session
33

4+
from mathicsscript import load_default_settings_files
5+
46

57
def test_settings():
6-
# FIXME: this is a start, but we should do more
7-
for setting in (
8-
"Settings`$ShowFullFormInput::usage",
9-
"Settings`$ShowFullFormInput",
10-
"Settings`$PygmentsStyle::usage",
11-
"Settings`$PygmentsShowTokens::usage",
12-
"Settings`$PygmentsShowTokens",
13-
"Settings`$UseUnicode::usage",
14-
"Settings`$UseUnicode",
15-
"Settings`MathicsScriptVersion::usage",
16-
):
17-
assert session.evaluate(setting), setting
8+
load_default_settings_files(session.definitions)
9+
10+
assert (
11+
session.evaluate("Settings`$ShowFullFormInput::usage").to_python()
12+
!= "Settings`$ShowFullFormInput::usage"
13+
)
14+
15+
assert type(session.evaluate("Settings`$ShowFullFormInput").to_python()) is bool
16+
17+
assert (
18+
session.evaluate("Settings`$PygmentsStyle::usage").to_python()
19+
!= "Settings`$PygmentsStyle::usage"
20+
)
21+
22+
assert (
23+
session.evaluate("Settings`$PygmentsShowTokens::usage").to_python()
24+
!= "Settings`$PygmentsShowTokens::usage"
25+
)
26+
27+
assert type(session.evaluate("Settings`$PygmentsShowTokens").to_python()) is bool
28+
29+
assert (
30+
session.evaluate("Settings`$UseUnicode::usage").to_python()
31+
!= "Settings`$UseUnicode::usage"
32+
)
33+
34+
assert type(session.evaluate("Settings`$UseUnicode").to_python()) is bool
35+
36+
assert (
37+
session.evaluate("Settings`MathicsScriptVersion::usage").to_python()
38+
!= "Settings`MathicsScriptVersion::usage"
39+
)
40+
41+
42+
def test_is_not_notebook():
43+
# the settings already were loaded
44+
assert session.evaluate("System`$Notebooks").to_python() == False

0 commit comments

Comments
 (0)