Skip to content

Commit

Permalink
Merge branch 'update-settings-test'
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Jun 23, 2021
2 parents 54dab81 + 99a0bf7 commit aad5dce
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 14 deletions.
12 changes: 11 additions & 1 deletion mathicsscript/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,14 @@
"""
from mathicsscript.version import __version__

__all__ = [__version__]

def load_default_settings_files(definitions):
import os.path as osp
from mathics.core.definitions import autoload_files

root_dir = osp.realpath(osp.dirname(__file__))

autoload_files(definitions, root_dir, "autoload")


__all__ = [__version__, load_default_settings_files]
2 changes: 1 addition & 1 deletion mathicsscript/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def get_completions(
words = []

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

if self.match_middle:
return word_before_cursor in word
Expand Down
51 changes: 39 additions & 12 deletions test/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
# -*- coding: utf-8 -*-
from .helper import session

from mathicsscript import load_default_settings_files


def test_settings():
# FIXME: this is a start, but we should do more
for setting in (
"Settings`$ShowFullFormInput::usage",
"Settings`$ShowFullFormInput",
"Settings`$PygmentsStyle::usage",
"Settings`$PygmentsShowTokens::usage",
"Settings`$PygmentsShowTokens",
"Settings`$UseUnicode::usage",
"Settings`$UseUnicode",
"Settings`MathicsScriptVersion::usage",
):
assert session.evaluate(setting), setting
load_default_settings_files(session.definitions)

assert (
session.evaluate("Settings`$ShowFullFormInput::usage").to_python()
!= "Settings`$ShowFullFormInput::usage"
)

assert type(session.evaluate("Settings`$ShowFullFormInput").to_python()) is bool

assert (
session.evaluate("Settings`$PygmentsStyle::usage").to_python()
!= "Settings`$PygmentsStyle::usage"
)

assert (
session.evaluate("Settings`$PygmentsShowTokens::usage").to_python()
!= "Settings`$PygmentsShowTokens::usage"
)

assert type(session.evaluate("Settings`$PygmentsShowTokens").to_python()) is bool

assert (
session.evaluate("Settings`$UseUnicode::usage").to_python()
!= "Settings`$UseUnicode::usage"
)

assert type(session.evaluate("Settings`$UseUnicode").to_python()) is bool

assert (
session.evaluate("Settings`MathicsScriptVersion::usage").to_python()
!= "Settings`MathicsScriptVersion::usage"
)


def test_is_not_notebook():
# the settings already were loaded
assert session.evaluate("System`$Notebooks").to_python() == False

0 comments on commit aad5dce

Please sign in to comment.