Merge pull request #1787 from Kodiologist/reload-test
Add a test for a previously fixed reloading bug
This commit is contained in:
commit
8215281968
@ -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"
|
||||
@ -238,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."""
|
||||
|
1
tests/resources/hello_world.hy
Normal file
1
tests/resources/hello_world.hy
Normal file
@ -0,0 +1 @@
|
||||
(print "hello world")
|
Loading…
Reference in New Issue
Block a user