Commit 0e25b164 by Gabriel Falcão

improving the import error for terrain.py and bumping to 0.1.16

parent 58c5c3f4
# lettuce # lettuce
> Version 0.1.15 - barium > Version 0.1.16 - barium
## On release names ## On release names
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
version = '0.1.15' version = '0.1.16'
release = 'barium' release = 'barium'
import os import os
...@@ -35,7 +35,7 @@ from lettuce.registry import call_hook ...@@ -35,7 +35,7 @@ from lettuce.registry import call_hook
from lettuce.registry import STEP_REGISTRY from lettuce.registry import STEP_REGISTRY
from lettuce.registry import CALLBACK_REGISTRY from lettuce.registry import CALLBACK_REGISTRY
from lettuce.exceptions import LettuceSyntaxError from lettuce import exceptions
__all__ = ['after', 'before', 'step', 'world', 'STEP_REGISTRY', 'CALLBACK_REGISTRY', 'call_hook'] __all__ = ['after', 'before', 'step', 'world', 'STEP_REGISTRY', 'CALLBACK_REGISTRY', 'call_hook']
...@@ -46,11 +46,12 @@ except Exception, e: ...@@ -46,11 +46,12 @@ except Exception, e:
if not "No module named terrain" in str(e): if not "No module named terrain" in str(e):
string = 'Lettuce has tried to load the conventional environment ' \ string = 'Lettuce has tried to load the conventional environment ' \
'module "terrain"\nbut it has errors, check its contents and ' \ 'module "terrain"\nbut it has errors, check its contents and ' \
'try to run lettuce again.\n' 'try to run lettuce again.\n\nOriginal traceback below:\n\n'
sys.stderr.write(string) sys.stderr.write(string)
sys.stderr.write(exceptions.traceback.format_exc(e))
raise SystemExit(1) raise SystemExit(1)
class Runner(object): class Runner(object):
""" Main lettuce's test runner """ Main lettuce's test runner
...@@ -109,7 +110,7 @@ class Runner(object): ...@@ -109,7 +110,7 @@ class Runner(object):
for filename in features_files: for filename in features_files:
feature = Feature.from_file(filename) feature = Feature.from_file(filename)
results.append(feature.run(self.scenarios)) results.append(feature.run(self.scenarios))
except LettuceSyntaxError, e: except exceptions.LettuceSyntaxError, e:
sys.stderr.write(e.msg) sys.stderr.write(e.msg)
failed = True failed = True
......
...@@ -18,7 +18,7 @@ import os ...@@ -18,7 +18,7 @@ import os
import lettuce import lettuce
from StringIO import StringIO from StringIO import StringIO
from os.path import dirname, abspath, join from os.path import dirname, join, abspath
from nose.tools import assert_equals, with_setup, assert_raises from nose.tools import assert_equals, with_setup, assert_raises
from lettuce.fs import FeatureLoader from lettuce.fs import FeatureLoader
from lettuce.core import Feature, fs, StepDefinition from lettuce.core import Feature, fs, StepDefinition
...@@ -59,10 +59,23 @@ def test_try_to_import_terrain(): ...@@ -59,10 +59,23 @@ def test_try_to_import_terrain():
reload(lettuce) reload(lettuce)
raise AssertionError('The runner should raise ImportError !') raise AssertionError('The runner should raise ImportError !')
except SystemExit: except SystemExit:
assert_stderr( assert_stderr_lines(
'Lettuce has tried to load the conventional environment module ' \ 'Lettuce has tried to load the conventional environment module ' \
'"terrain"\n' '"terrain"\nbut it has errors, check its contents and ' \
'but it has errors, check its contents and try to run lettuce again.\n' 'try to run lettuce again.\n\nOriginal traceback below:\n\n' \
"Traceback (most recent call last):\n"
' File "%(lettuce_core_file)s", line 43, in <module>\n'
' terrain = fs.FileSystem._import("terrain")\n' \
' File "%(lettuce_fs_file)s", line 63, in _import\n' \
' module = imp.load_module(name, fp, pathname, description)\n' \
' File "%(terrain_file)s", line 18\n' \
' it is here just to cause a syntax error\n' \
" ^\n" \
'SyntaxError: invalid syntax\n' % {
'lettuce_core_file': abspath(join(lettuce_dir, '__init__.py')),
'lettuce_fs_file': abspath(join(lettuce_dir, 'fs.py')),
'terrain_file': abspath(lettuce_path('..', 'tests', 'functional', 'sandbox', 'terrain.py')),
}
) )
finally: finally:
......
...@@ -21,7 +21,7 @@ from mox import Mox ...@@ -21,7 +21,7 @@ from mox import Mox
def test_has_version(): def test_has_version():
"A nice python module is supposed to have a version" "A nice python module is supposed to have a version"
assert_equals(lettuce.version, '0.1.15') assert_equals(lettuce.version, '0.1.16')
def test_import(): def test_import():
"lettuce importer does import" "lettuce importer does import"
...@@ -31,18 +31,23 @@ def test_import(): ...@@ -31,18 +31,23 @@ def test_import():
def test_terrain_import_exception(): def test_terrain_import_exception():
"lettuce error tries to import " "lettuce error tries to import "
string = 'Lettuce has tried to load the conventional environment ' \ string = 'Lettuce has tried to load the conventional environment ' \
'module "terrain"\nbut it has errors, check its contents and ' \ 'module "terrain"\nbut it has errors, check its contents and ' \
'try to run lettuce again.\n' 'try to run lettuce again.\n\nOriginal traceback below:\n\n'
mox = Mox() mox = Mox()
mox.StubOutWithMock(lettuce.fs, 'FileSystem') mox.StubOutWithMock(lettuce.fs, 'FileSystem')
mox.StubOutWithMock(lettuce.exceptions, 'traceback')
mox.StubOutWithMock(lettuce.sys, 'stderr') mox.StubOutWithMock(lettuce.sys, 'stderr')
lettuce.fs.FileSystem._import('terrain').AndRaise(Exception('foo bar')) exc = Exception('foo bar')
lettuce.fs.FileSystem._import('terrain').AndRaise(exc)
lettuce.exceptions.traceback.format_exc(exc).AndReturn('I AM THE TRACEBACK FOR IMPORT ERROR')
lettuce.sys.stderr.write(string) lettuce.sys.stderr.write(string)
lettuce.sys.stderr.write('I AM THE TRACEBACK FOR IMPORT ERROR')
mox.ReplayAll() mox.ReplayAll()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment