Skip to content

Commit 3025fb4

Browse files
committed
update
1 parent 2cca637 commit 3025fb4

File tree

3 files changed

+106
-1
lines changed

3 files changed

+106
-1
lines changed

Makefile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# A GNU Makefile to run various tasks - compatibility for us old-timers.
2+
3+
# Note: This makefile include remake-style target comments.
4+
# These comments before the targets start with #:
5+
# remake --tasks to shows the targets and the comments
6+
7+
GIT2CL ?= admin-tools/git2cl
8+
PYTHON ?= python
9+
PIP ?= $(PYTHON) -m pip
10+
RM ?= rm
11+
12+
13+
.PHONY: all build \
14+
check clean \
15+
develop dist doc doc-data \
16+
pypi-setup \
17+
pytest \
18+
rmChangeLog \
19+
test
20+
21+
#: Default target - same as "develop"
22+
all: develop
23+
24+
#: build everything needed to install
25+
build: pypi-setup
26+
$(PYTHON) ./setup.py build
27+
28+
#: Check Python version, and install PyPI dependencies
29+
pypi-setup:
30+
$(PIP) install -e .
31+
32+
#: Set up to run from the source tree
33+
develop: pypi-setup
34+
35+
#: Make distirbution: wheels, eggs, tarball
36+
dist:
37+
./admin-tools/make-dist.sh
38+
39+
#: Install pymathics.graph
40+
install: pypi-setup
41+
$(PYTHON) setup.py install
42+
43+
# Run tests
44+
test check: pytest doctest
45+
46+
#: Remove derived files
47+
clean: clean-pyc
48+
49+
#: Remove old PYC files
50+
clean-pyc:
51+
@find . -name "*.pyc" -type f -delete
52+
53+
#: Run py.test tests. Use environment variable "o" for pytest options
54+
pytest:
55+
MATHICS_CHARACTER_ENCODING="ASCII" $(PYTHON) -m pytest $(PYTEST_WORKERS) test $o
56+
57+
58+
# #: Create data that is used to in Django docs and to build TeX PDF
59+
# doc-data mathics/doc/tex/data: mathics/builtin/*.py mathics/doc/documentation/*.mdoc mathics/doc/documentation/images/*
60+
# $(PYTHON) mathics/test.py -ot -k
61+
62+
#: Run tests that appear in docstring in the code.
63+
doctest:
64+
MATHICS_CHARACTER_ENCODING="ASCII" $(PYTHON) -m mathics.docpipeline -l pymathics.language -c "Pymathics Language" $o
65+
66+
# #: Make Mathics PDF manual
67+
# doc mathics.pdf: mathics/doc/tex/data
68+
# (cd mathics/doc/tex && $(MAKE) mathics.pdf)
69+
70+
#: Remove ChangeLog
71+
rmChangeLog:
72+
$(RM) ChangeLog || true
73+
74+
#: Create a ChangeLog from git via git log and git2cl
75+
ChangeLog: rmChangeLog
76+
git log --pretty --numstat --summary | $(GIT2CL) >$@
77+
78+
79+
#: Run pytest consistency and style checks
80+
check-consistency-and-style:
81+
MATHICS_LINT=t $(PYTHON) -m pytest test/consistency-and-style

pymathics/language/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from typing import List, Optional
1414

1515
from mathics.core.atoms import String
16-
from mathics.core.base import Builtin
16+
from mathics.core.builtin import Builtin
1717
from mathics.core.convert.expression import to_mathics_list
1818

1919
availableLocales = Locale.getAvailableLocales()

test/test_language.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from mathics.core.load_builtin import import_and_load_builtins
4+
from mathics.session import MathicsSession
5+
6+
import_and_load_builtins()
7+
8+
session = MathicsSession(character_encoding="ASCII")
9+
10+
11+
def check_evaluation(str_expr: str, expected: str, message=""):
12+
"""Helper function to test that a Mathics expression against
13+
its results"""
14+
result = session.evaluate(str_expr).value
15+
16+
if message:
17+
assert result == expected, f"{message}: got: {result}"
18+
else:
19+
assert result == expected
20+
21+
22+
def test_hello():
23+
session.evaluate('LoadModule["pymathics.language"]') == "pymathics.language"
24+
check_evaluation('Alphabet["es"]//Length', 33)

0 commit comments

Comments
 (0)