diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 816038e1..cf170eb7 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -54,9 +54,11 @@ jobs: python -m pip install --upgrade pip pip install -r requirements-dev.txt - name: Test install with pytest (including doctests) + env: + PYTHONWARNINGS: error run: | python -c "import tests" # Compiles hissp.basic on package import. - pytest -v --cov=hissp --cov-report=xml --doctest-modules --doctest-glob *.md src/hissp/*.lissp tests/ docs/ $(python -c "import hissp; print(hissp.__path__[0])") + pytest -p no:cacheprovider -v --cov=hissp --cov-report=xml --doctest-modules --doctest-glob *.md src/hissp/*.lissp tests/ docs/ $(python -c "import hissp; print(hissp.__path__[0])") - name: Codecov uses: codecov/codecov-action@v1.0.4 with: diff --git a/src/hissp/reader.py b/src/hissp/reader.py index cdc438fb..17d99ae4 100644 --- a/src/hissp/reader.py +++ b/src/hissp/reader.py @@ -140,7 +140,7 @@ def __init__(self, token): self.token = token def contents(self): - return re.sub(r"\n$|(?m)^ *;+ ?", "", self.token) + return re.sub(r"(?m)\n$|^ *;+ ?", "", self.token) def __repr__(self): return f"Comment({self.token!r})" diff --git a/src/hissp/repl.py b/src/hissp/repl.py index be651add..bf222b9d 100644 --- a/src/hissp/repl.py +++ b/src/hissp/repl.py @@ -88,29 +88,22 @@ def interact(locals=None): def force_main(): """:meta private:""" + # Creates a new ``__main__`` to take the place of the current + # ``__main__`` module. __main__ = ModuleType("__main__") sys.modules["__main__"] = __main__ sys.path.insert(0, "") return __main__ -def main(__main__=None): +def main(__main__): """REPL command-line entry point. - If ``__main__`` is not provided, it creates a new one to take the - place of the current ``__main__`` module. - `hissp.macros._macro_` is imported into the module namespace, making the bundled macros immediately available unqualified. """ - if not __main__: - __main__ = force_main() repl = LisspREPL(locals=__main__.__dict__) import hissp.macros # Here so repl can import before compilation. repl.locals["_macro_"] = SimpleNamespace(**vars(hissp.macros._macro_)) repl.interact() - - -if __name__ == "__main__": - main() diff --git a/tests/test_cmd.py b/tests/test_cmd.py index ef67d839..762810b8 100644 --- a/tests/test_cmd.py +++ b/tests/test_cmd.py @@ -53,7 +53,7 @@ def test_i_file_args(): def test_repl_read_exception(): - out, err = cmd("python -m hissp.repl", ".#(operator..truediv 1 0)\n") + out, err = cmd("python -m hissp", ".#(operator..truediv 1 0)\n") assert ">>> # Compilation failed!\nTraceback (most recent call last):\n F" in err assert "\nZeroDivisionError: division by zero" in err assert out.count("#> ") == 2