diff --git a/.gitignore b/.gitignore
index f1cb8d0..503fc27 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,4 +8,4 @@
dist
.coverage
build/
-.noseids
+/.cache
diff --git a/Makefile b/Makefile
index 7913fea..1b618a7 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,6 @@ pip_url=https://bootstrap.pypa.io/get-pip.py
python=python
pip=pip
coveralls=coveralls
-nose=nosetests
all:
@echo "No default step. Use setup.py"
@@ -41,7 +40,7 @@ endif
dev: test flake
test: venv
- nosetests -sv
+ pytest
tox: venv
tox
diff --git a/conftest.py b/conftest.py
new file mode 100644
index 0000000..72fa553
--- /dev/null
+++ b/conftest.py
@@ -0,0 +1,13 @@
+import _pytest
+import hy
+from hy._compat import PY3
+
+def pytest_collect_file(parent, path):
+ if (path.ext == ".hy"
+ and "/tests/native_tests/" in path.dirname + "/"
+ and path.basename != "__init__.hy"
+ and not ("py3_only" in path.basename and not PY3)):
+ m = _pytest.python.pytest_pycollect_makemodule(path, parent)
+ # Spoof the module name to avoid hitting an assertion in pytest.
+ m.name = m.name[:-len(".hy")] + ".py"
+ return m
diff --git a/docs/hacking.rst b/docs/hacking.rst
index 4042208..707745d 100644
--- a/docs/hacking.rst
+++ b/docs/hacking.rst
@@ -62,12 +62,11 @@ Do this:
Test!
=====
-Tests are located in ``tests/``. We use `nose
-`_.
+Tests are located in ``tests/``. We use `pytest `_.
To run the tests::
- $ nosetests
+ $ pytest
Write tests---tests are good!
diff --git a/hy/importer.py b/hy/importer.py
index fc9a273..f49129c 100644
--- a/hy/importer.py
+++ b/hy/importer.py
@@ -30,7 +30,6 @@ import marshal
import struct
import imp
import sys
-import platform
import ast
import os
import __future__
@@ -114,17 +113,13 @@ def import_file_to_module(module_name, fpath, loader=None):
module = imp.new_module(module_name)
module.__file__ = fpath
code = ast_compile(_ast, fpath, "exec")
- if not (platform.python_implementation() == 'PyPy' and
- 'nosetests' in sys.argv[0] and
- is_package(module_name)):
- # Nose can generate spurious errors in this specific situation.
- try:
- write_code_as_pyc(fpath, code)
- except (IOError, OSError):
- # We failed to save the bytecode, probably because of a
- # permissions issue. The user only asked to import the
- # file, so don't bug them about it.
- pass
+ try:
+ write_code_as_pyc(fpath, code)
+ except (IOError, OSError):
+ # We failed to save the bytecode, probably because of a
+ # permissions issue. The user only asked to import the
+ # file, so don't bug them about it.
+ pass
eval(code, module.__dict__)
except (HyTypeError, LexException) as e:
if e.source is None:
diff --git a/make.bat b/make.bat
index 2551ea2..1a010bc 100644
--- a/make.bat
+++ b/make.bat
@@ -55,7 +55,7 @@ goto :EOF
if "%1" == "test" (
:test
call :venv
- nosetests -sv
+ pytest -sv
goto :EOF
)
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 63b9481..4e197a9 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,6 +1,6 @@
-r requirements-travis.txt
# test tools
-nose
+pytest
tox
# documentation
diff --git a/setup.cfg b/setup.cfg
index 31c8825..3923777 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,9 +1,3 @@
-[nosetests]
-detailed-errors=1
-with-coverage=1
-cover-package=hy
-nocapture=1
-
[wheel]
universal = 1
@@ -12,7 +6,6 @@ omit =
*/python?.?/*
*/lib-python/?.?/*.py
*/lib_pypy/_*.py
- */site-packages/nose/*
*/pypy/*
[coverage:report]
@@ -22,3 +15,8 @@ exclude_lines =
# We want ignore_errors so we don't get NoSource warnings for loading
# byte-compiled Hy modules.
ignore_errors = True
+
+[tool:pytest]
+# Be sure to include Hy test functions whose names end with "?",
+# which will be mangled to begin with "is_".
+python_functions=test_* is_test_*
diff --git a/tests/__init__.py b/tests/__init__.py
index 1fbc6c6..e69de29 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,25 +0,0 @@
-
-import hy # noqa
-from hy._compat import PY3
-from .native_tests.cons import * # noqa
-from .native_tests.defclass import * # noqa
-from .native_tests.mathematics import * # noqa
-from .native_tests.native_macros import * # noqa
-from .native_tests.quote import * # noqa
-from .native_tests.language import * # noqa
-from .native_tests.unless import * # noqa
-from .native_tests.when import * # noqa
-from .native_tests.with_decorator import * # noqa
-from .native_tests.core import * # noqa
-from .native_tests.sharp_macros import * # noqa
-from .native_tests.operators import * # noqa
-from .native_tests.with_test import * # noqa
-from .native_tests.extra.anaphoric import * # noqa
-from .native_tests.contrib.loop import * # noqa
-from .native_tests.contrib.walk import * # noqa
-from .native_tests.contrib.multi import * # noqa
-from .native_tests.contrib.sequences import * # noqa
-from .native_tests.contrib.hy_repr import * # noqa
-
-if PY3:
- from .native_tests.py3_only_tests import * # noqa
diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy
index 6470130..28c9d02 100644
--- a/tests/native_tests/language.hy
+++ b/tests/native_tests/language.hy
@@ -1315,8 +1315,7 @@
(defn test-calling-module-name []
"NATIVE: Test the calling-module-name function"
- (assert (= (calling-module-name -1) "hy.core.language"))
- (assert (= (calling-module-name 0) "tests.native_tests.language")))
+ (assert (= (calling-module-name -1) "hy.core.language")))
(defn test-disassemble []
diff --git a/tests/native_tests/py3_only_tests.hy b/tests/native_tests/py3_only_tests.hy
index 6c577b4..365a4fe 100644
--- a/tests/native_tests/py3_only_tests.hy
+++ b/tests/native_tests/py3_only_tests.hy
@@ -1,8 +1,5 @@
;; Tests where the emitted code relies on Python 3.
-;; Conditionally included in nosetests runs.
-
-(import [hy.errors [HyCompileError]])
-
+;; conftest.py skips this file when running on Python 2.
(defn test-exception-cause []
diff --git a/tox.ini b/tox.ini
index a4ab4f0..6f0d909 100644
--- a/tox.ini
+++ b/tox.ini
@@ -5,7 +5,7 @@ skipsdist = True
[testenv]
commands =
pip install --allow-all-external -e .
- nosetests
+ pytest
passenv =
TERM
deps =