From e436d9dd4df4df65a422868f99374fdef40753bc Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Fri, 21 Jun 2019 15:45:04 -0400 Subject: [PATCH 1/2] Remove an obsolete check for `importlib.reload` --- tests/importer/test_importer.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/importer/test_importer.py b/tests/importer/test_importer.py index a823c41..a604a73 100644 --- a/tests/importer/test_importer.py +++ b/tests/importer/test_importer.py @@ -10,6 +10,7 @@ import runpy import importlib from fractions import Fraction +from importlib import reload import pytest @@ -20,11 +21,6 @@ from hy.lex.exceptions import PrematureEndOfInput from hy.compiler import hy_eval, hy_compile from hy.importer import HyLoader -try: - from importlib import reload -except ImportError: - from imp import reload - def test_basics(): "Make sure the basics of the importer work" From eb265181bf36cfd1d64bc180758b5bb92a4204f8 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Fri, 28 Jun 2019 13:41:14 -0400 Subject: [PATCH 2/2] Add a test for a previously fixed reloading bug --- tests/importer/test_importer.py | 12 ++++++++++++ tests/resources/hello_world.hy | 1 + 2 files changed, 13 insertions(+) create mode 100644 tests/resources/hello_world.hy diff --git a/tests/importer/test_importer.py b/tests/importer/test_importer.py index a604a73..aba89e4 100644 --- a/tests/importer/test_importer.py +++ b/tests/importer/test_importer.py @@ -234,6 +234,18 @@ def test_reload(): unlink(source) +def test_reload_reexecute(capsys): + """A module is re-executed when it's reloaded, even if it's + unchanged. + + https://github.com/hylang/hy/issues/712""" + import tests.resources.hello_world + assert capsys.readouterr().out == 'hello world\n' + assert capsys.readouterr().out == '' + reload(tests.resources.hello_world) + assert capsys.readouterr().out == 'hello world\n' + + def test_circular(): """Test circular imports by creating a temporary file/module that calls a function that imports itself.""" diff --git a/tests/resources/hello_world.hy b/tests/resources/hello_world.hy new file mode 100644 index 0000000..a566b8a --- /dev/null +++ b/tests/resources/hello_world.hy @@ -0,0 +1 @@ +(print "hello world")