Merge pull request #1787 from Kodiologist/reload-test

Add a test for a previously fixed reloading bug
This commit is contained in:
Kodi Arfer 2019-07-06 14:53:20 -04:00 committed by GitHub
commit 8215281968
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -10,6 +10,7 @@ import runpy
import importlib import importlib
from fractions import Fraction from fractions import Fraction
from importlib import reload
import pytest import pytest
@ -20,11 +21,6 @@ from hy.lex.exceptions import PrematureEndOfInput
from hy.compiler import hy_eval, hy_compile from hy.compiler import hy_eval, hy_compile
from hy.importer import HyLoader from hy.importer import HyLoader
try:
from importlib import reload
except ImportError:
from imp import reload
def test_basics(): def test_basics():
"Make sure the basics of the importer work" "Make sure the basics of the importer work"
@ -238,6 +234,18 @@ def test_reload():
unlink(source) 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(): def test_circular():
"""Test circular imports by creating a temporary file/module that calls a """Test circular imports by creating a temporary file/module that calls a
function that imports itself.""" function that imports itself."""

View File

@ -0,0 +1 @@
(print "hello world")