From f9db6f223d784c724a38c8f5b8d9f9c8b679c190 Mon Sep 17 00:00:00 2001 From: Tiago Cavalcante Trindade Date: Wed, 23 Jun 2021 11:08:50 -0300 Subject: [PATCH] Add load_default_settings_files function --- mathicsscript/__init__.py | 12 ++++++++++++ test/test_settings.py | 39 +++++++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/mathicsscript/__init__.py b/mathicsscript/__init__.py index 1f73734..f6813b1 100644 --- a/mathicsscript/__init__.py +++ b/mathicsscript/__init__.py @@ -5,3 +5,15 @@ Copyright 2020-2021 The Mathics Team """ from mathicsscript.version import __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] diff --git a/test/test_settings.py b/test/test_settings.py index 6f389cc..d32c05f 100644 --- a/test/test_settings.py +++ b/test/test_settings.py @@ -1,37 +1,44 @@ # -*- coding: utf-8 -*- from .helper import session -import os.path as osp +from mathicsscript import load_default_settings_files -from mathics.core.definitions import autoload_files, Definitions def test_settings(): - import os.path as osp - from mathics.core.definitions import autoload_files - import mathicsscript + load_default_settings_files(session.definitions) - root_dir = osp.realpath( - osp.dirname(mathicsscript.__file__), + assert ( + session.evaluate("Settings`$ShowFullFormInput::usage").to_python() + != "Settings`$ShowFullFormInput::usage" ) - autoload_files(session.definitions, root_dir, "autoload") - - 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`$PygmentsStyle::usage").to_python() + != "Settings`$PygmentsStyle::usage" + ) - assert session.evaluate("Settings`$PygmentsShowTokens::usage").to_python() != "Settings`$PygmentsShowTokens::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 ( + 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" + assert ( + session.evaluate("Settings`MathicsScriptVersion::usage").to_python() + != "Settings`MathicsScriptVersion::usage" + ) + def test_is_not_notebook(): - # the settings already were loaded + # the settings already were loaded assert session.evaluate("System`$Notebooks").to_python() == False