Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lettuce
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
lettuce
Commits
8f427a54
Commit
8f427a54
authored
Aug 27, 2015
by
Gabriel Falcão
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #466 from dnozay/root_dir
add --root-dir option so discovery does not go up all the way to '/'
parents
bd2c007c
910f08b0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
5 deletions
+19
-5
lettuce/__init__.py
+2
-2
lettuce/bin.py
+8
-0
lettuce/fs.py
+8
-2
tests/unit/test_terrain.py
+1
-1
No files found.
lettuce/__init__.py
View file @
8f427a54
...
@@ -94,7 +94,7 @@ class Runner(object):
...
@@ -94,7 +94,7 @@ class Runner(object):
enable_xunit
=
False
,
xunit_filename
=
None
,
enable_xunit
=
False
,
xunit_filename
=
None
,
enable_subunit
=
False
,
subunit_filename
=
None
,
enable_subunit
=
False
,
subunit_filename
=
None
,
tags
=
None
,
failfast
=
False
,
auto_pdb
=
False
,
tags
=
None
,
failfast
=
False
,
auto_pdb
=
False
,
smtp_queue
=
None
):
smtp_queue
=
None
,
root_dir
=
None
):
""" lettuce.Runner will try to find a terrain.py file and
""" lettuce.Runner will try to find a terrain.py file and
import it from within `base_path`
import it from within `base_path`
...
@@ -108,7 +108,7 @@ class Runner(object):
...
@@ -108,7 +108,7 @@ class Runner(object):
base_path
=
os
.
path
.
dirname
(
base_path
)
base_path
=
os
.
path
.
dirname
(
base_path
)
sys
.
path
.
insert
(
0
,
base_path
)
sys
.
path
.
insert
(
0
,
base_path
)
self
.
loader
=
fs
.
FeatureLoader
(
base_path
)
self
.
loader
=
fs
.
FeatureLoader
(
base_path
,
root_dir
)
self
.
verbosity
=
verbosity
self
.
verbosity
=
verbosity
self
.
scenarios
=
scenarios
and
map
(
int
,
scenarios
.
split
(
","
))
or
None
self
.
scenarios
=
scenarios
and
map
(
int
,
scenarios
.
split
(
","
))
or
None
self
.
failfast
=
failfast
self
.
failfast
=
failfast
...
...
lettuce/bin.py
View file @
8f427a54
...
@@ -59,6 +59,13 @@ def main(args=sys.argv[1:]):
...
@@ -59,6 +59,13 @@ def main(args=sys.argv[1:]):
default
=
False
,
default
=
False
,
help
=
"Run scenarios in a more random order to avoid interference"
)
help
=
"Run scenarios in a more random order to avoid interference"
)
parser
.
add_option
(
"--root-dir"
,
dest
=
"root_dir"
,
default
=
"/"
,
type
=
"string"
,
help
=
"Tells lettuce not to search for features/steps "
" above this directory."
)
parser
.
add_option
(
"--with-xunit"
,
parser
.
add_option
(
"--with-xunit"
,
dest
=
"enable_xunit"
,
dest
=
"enable_xunit"
,
action
=
"store_true"
,
action
=
"store_true"
,
...
@@ -121,6 +128,7 @@ def main(args=sys.argv[1:]):
...
@@ -121,6 +128,7 @@ def main(args=sys.argv[1:]):
failfast
=
options
.
failfast
,
failfast
=
options
.
failfast
,
auto_pdb
=
options
.
auto_pdb
,
auto_pdb
=
options
.
auto_pdb
,
tags
=
tags
,
tags
=
tags
,
root_dir
=
options
.
root_dir
,
)
)
result
=
runner
.
run
()
result
=
runner
.
run
()
...
...
lettuce/fs.py
View file @
8f427a54
...
@@ -30,17 +30,23 @@ from os.path import abspath, join, dirname, curdir, exists
...
@@ -30,17 +30,23 @@ from os.path import abspath, join, dirname, curdir, exists
class
FeatureLoader
(
object
):
class
FeatureLoader
(
object
):
"""Loader class responsible for findind features and step
"""Loader class responsible for findind features and step
definitions along a given path on filesystem"""
definitions along a given path on filesystem"""
def
__init__
(
self
,
base_dir
):
def
__init__
(
self
,
base_dir
,
root_dir
=
None
):
self
.
base_dir
=
FileSystem
.
abspath
(
base_dir
)
self
.
base_dir
=
FileSystem
.
abspath
(
base_dir
)
if
root_dir
is
None
:
root_dir
=
'/'
self
.
root_dir
=
FileSystem
.
abspath
(
root_dir
)
def
find_and_load_step_definitions
(
self
):
def
find_and_load_step_definitions
(
self
):
# find steps, possibly up several directories
# find steps, possibly up several directories
base_dir
=
self
.
base_dir
base_dir
=
self
.
base_dir
while
base_dir
!=
'/'
:
while
base_dir
!=
self
.
root_dir
:
files
=
FileSystem
.
locate
(
base_dir
,
'*.py'
)
files
=
FileSystem
.
locate
(
base_dir
,
'*.py'
)
if
files
:
if
files
:
break
break
base_dir
=
FileSystem
.
join
(
base_dir
,
'..'
)
base_dir
=
FileSystem
.
join
(
base_dir
,
'..'
)
else
:
# went as far as root_dir, also discover files under root_dir
files
=
FileSystem
.
locate
(
base_dir
,
'*.py'
)
for
filename
in
files
:
for
filename
in
files
:
root
=
FileSystem
.
dirname
(
filename
)
root
=
FileSystem
.
dirname
(
filename
)
...
...
tests/unit/test_terrain.py
View file @
8f427a54
...
@@ -181,7 +181,7 @@ def test_after_each_all_is_executed_before_each_all():
...
@@ -181,7 +181,7 @@ def test_after_each_all_is_executed_before_each_all():
mox
.
StubOutWithMock
(
lettuce
.
fs
,
'FileSystem'
)
mox
.
StubOutWithMock
(
lettuce
.
fs
,
'FileSystem'
)
mox
.
StubOutWithMock
(
lettuce
,
'Feature'
)
mox
.
StubOutWithMock
(
lettuce
,
'Feature'
)
lettuce
.
fs
.
FeatureLoader
(
'some_basepath'
)
.
AndReturn
(
loader_mock
)
lettuce
.
fs
.
FeatureLoader
(
'some_basepath'
,
None
)
.
AndReturn
(
loader_mock
)
lettuce
.
sys
.
path
.
insert
(
0
,
'some_basepath'
)
lettuce
.
sys
.
path
.
insert
(
0
,
'some_basepath'
)
lettuce
.
sys
.
path
.
remove
(
'some_basepath'
)
lettuce
.
sys
.
path
.
remove
(
'some_basepath'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment